use of com.sun.xml.ws.api.addressing.AddressingVersion in project metro-jax-ws by eclipse-ee4j.
the class GenerateToElementTest method testCorrectToFromResMsg.
public void testCorrectToFromResMsg() throws Exception {
String reqMsgStr = "<s:Envelope xmlns:s=\"http://schemas.xmlsoap.org/soap/envelope/\" xmlns:a=\"http://www.w3.org/2005/08/addressing\">" + "<s:Header>" + "<a:Action s:mustUnderstand=\"1\">http://example.org/action/echoIn</a:Action>" + "<a:ReplyTo s:actor=\"http://www.w3.org/2003/05/soap-envelope/role/none\"><a:Address>http://www.microsoft.com/</a:Address></a:ReplyTo>" + "<a:MessageID>urn:uuid:d715800d-67e2-4254-a86e-e31a1bfaecab</a:MessageID>" + "<a:ReplyTo><a:Address>http://10.244.13.245:8000/2eaddcdf-e10b-41c5-9f1f-a7ac50853fc3/4b1de783-1499-4419-9634-465f8797a0a8</a:Address></a:ReplyTo>" + "<a:To s:mustUnderstand=\"1\">http://scl58353.us.oracle.com:9902/WSAddressingCR_Service_WCF/WSAddressing10.svc/Echo4</a:To>" + "</s:Header>" + "<s:Body>" + "<echoIn xmlns=\"http://example.org/echo\">test1151</echoIn>" + "</s:Body>" + "</s:Envelope>";
String respMsgStr = "<?xml version='1.0' encoding='UTF-8'?>" + "<S:Envelope xmlns:S=\"http://schemas.xmlsoap.org/soap/envelope/\">" + "<S:Body>" + "<ns0:echoOut xmlns:ns0=\"http://example.org/echo\">test1151</ns0:echoOut>" + "</S:Body>" + "</S:Envelope>";
String finalToFromResponseMsg = "";
WSEndpointReference originalReplyToFromRequestMsg = null;
AddressingVersion av = AddressingVersion.W3C;
SOAPVersion sv = SOAPVersion.SOAP_11;
String action = "http://example.org/action/echoOut";
SAAJMessage reqMsg = new SAAJMessage(makeSOAPMessage(reqMsgStr));
SAAJMessage respMsg = new SAAJMessage(makeSOAPMessage(respMsgStr));
HeaderList requestHdrs = (HeaderList) reqMsg.getHeaders();
originalReplyToFromRequestMsg = requestHdrs.getReplyTo(av, sv);
Packet responsePacket = null;
try {
responsePacket = new Packet(reqMsg).createServerResponse(respMsg, av, sv, action);
} catch (Exception e) {
e.printStackTrace();
}
// check toHeader
finalToFromResponseMsg = AddressingUtils.getTo(responsePacket.getHeaderList(), av, sv);
assertEquals(finalToFromResponseMsg, originalReplyToFromRequestMsg.getAddress());
}
use of com.sun.xml.ws.api.addressing.AddressingVersion in project metro-jax-ws by eclipse-ee4j.
the class Messages method createAddressingFaultMessage.
/**
* Creates a fault {@link Message} that captures the code/subcode/subsubcode
* defined by WS-Addressing if one of the expected WS-Addressing headers is
* missing in the message
*
* @param binding WSBinding
* @param p
* {@link Packet} that was missing a WS-Addressing header.
* @param missingHeader The missing WS-Addressing Header
* @return
* A message representing SOAPFault that contains the WS-Addressing code/subcode/subsubcode.
*/
public static Message createAddressingFaultMessage(WSBinding binding, Packet p, QName missingHeader) {
AddressingVersion av = binding.getAddressingVersion();
if (av == null) {
// Addressing is not enabled.
throw new WebServiceException(AddressingMessages.ADDRESSING_SHOULD_BE_ENABLED());
}
WsaTubeHelper helper = av.getWsaHelper(null, null, binding);
return create(helper.newMapRequiredFault(new MissingAddressingHeaderException(missingHeader, p)));
}
use of com.sun.xml.ws.api.addressing.AddressingVersion in project metro-jax-ws by eclipse-ee4j.
the class Packet method populateAddressingHeaders.
private void populateAddressingHeaders(WSBinding binding, Packet responsePacket, WSDLPort wsdlPort, SEIModel seiModel) {
AddressingVersion addressingVersion = binding.getAddressingVersion();
if (addressingVersion == null) {
return;
}
WsaTubeHelper wsaHelper = addressingVersion.getWsaHelper(wsdlPort, seiModel, binding);
String action = responsePacket.getMessage().isFault() ? wsaHelper.getFaultAction(this, responsePacket) : wsaHelper.getOutputAction(this);
if (action == null) {
LOGGER.info("WSA headers are not added as value for wsa:Action cannot be resolved for this message");
return;
}
populateAddressingHeaders(responsePacket, addressingVersion, binding.getSOAPVersion(), action, AddressingVersion.isRequired(binding));
}
use of com.sun.xml.ws.api.addressing.AddressingVersion in project metro-jax-ws by eclipse-ee4j.
the class Packet method relateServerResponse.
public Packet relateServerResponse(@Nullable Packet r, @Nullable WSDLPort wsdlPort, @Nullable SEIModel seiModel, @NotNull WSBinding binding) {
relatePackets(r, false);
r.setState(State.ServerResponse);
AddressingVersion av = binding.getAddressingVersion();
// populate WS-A headers only if WS-A is enabled
if (av == null) {
return r;
}
if (getMessage() == null) {
return r;
}
// populate WS-A headers only if the request has addressing headers
String inputAction = AddressingUtils.getAction(getMessage().getHeaders(), av, binding.getSOAPVersion());
if (inputAction == null) {
return r;
}
// if one-way, then dont populate any WS-A headers
if (r.getMessage() == null || (wsdlPort != null && getMessage().isOneWay(wsdlPort))) {
return r;
}
// otherwise populate WS-Addressing headers
populateAddressingHeaders(binding, r, wsdlPort, seiModel);
return r;
}
use of com.sun.xml.ws.api.addressing.AddressingVersion in project metro-jax-ws by eclipse-ee4j.
the class Stub method getWSEndpointReference.
@Override
public final WSEndpointReference getWSEndpointReference() {
if (binding.getBindingID().equals(HTTPBinding.HTTP_BINDING)) {
throw new java.lang.UnsupportedOperationException(ClientMessages.UNSUPPORTED_OPERATION("BindingProvider.getEndpointReference(Class<T> class)", "XML/HTTP Binding", "SOAP11 or SOAP12 Binding"));
}
if (endpointReference != null) {
return endpointReference;
}
String eprAddress = requestContext.getEndpointAddress().toString();
QName portTypeName = null;
String wsdlAddress = null;
List<WSEndpointReference.EPRExtension> wsdlEPRExtensions = new ArrayList<>();
if (wsdlPort != null) {
portTypeName = wsdlPort.getBinding().getPortTypeName();
wsdlAddress = eprAddress + "?wsdl";
// gather EPRExtensions specified in WSDL.
try {
WSEndpointReference wsdlEpr = wsdlPort.getEPR();
if (wsdlEpr != null) {
for (WSEndpointReference.EPRExtension extnEl : wsdlEpr.getEPRExtensions()) {
wsdlEPRExtensions.add(new WSEPRExtension(XMLStreamBuffer.createNewBufferFromXMLStreamReader(extnEl.readAsXMLStreamReader()), extnEl.getQName()));
}
}
} catch (XMLStreamException ex) {
throw new WebServiceException(ex);
}
}
AddressingVersion av = AddressingVersion.W3C;
this.endpointReference = new WSEndpointReference(av, eprAddress, getServiceName(), getPortName(), portTypeName, null, wsdlAddress, null, wsdlEPRExtensions, null);
return this.endpointReference;
}
Aggregations