use of com.sun.xml.ws.api.SOAPVersion 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.SOAPVersion in project metro-jax-ws by eclipse-ee4j.
the class Messages method create.
/**
* Creates a {@link Message} from an {@link Element} that represents
* the whole SOAP message.
*
* @param soapEnvelope
* The SOAP envelope element.
*/
public static Message create(Element soapEnvelope) {
SOAPVersion ver = SOAPVersion.fromNsUri(soapEnvelope.getNamespaceURI());
// find the headers
Element header = DOMUtil.getFirstChild(soapEnvelope, ver.nsUri, "Header");
HeaderList headers = null;
if (header != null) {
for (Node n = header.getFirstChild(); n != null; n = n.getNextSibling()) {
if (n.getNodeType() == Node.ELEMENT_NODE) {
if (headers == null)
headers = new HeaderList(ver);
headers.add(Headers.create((Element) n));
}
}
}
// find the payload
Element body = DOMUtil.getFirstChild(soapEnvelope, ver.nsUri, "Body");
if (body == null)
throw new WebServiceException("Message doesn't have <S:Body> " + soapEnvelope);
Element payload = DOMUtil.getFirstChild(soapEnvelope, ver.nsUri, "Body");
if (payload == null) {
return new EmptyMessageImpl(headers, new AttachmentSetImpl(), ver);
} else {
return new DOMMessage(ver, headers, payload);
}
}
use of com.sun.xml.ws.api.SOAPVersion in project metro-jax-ws by eclipse-ee4j.
the class StreamMessage method readEnvelope.
private static void readEnvelope(StreamMessage message) {
if (message.envelopeReader == null)
return;
XMLStreamReader reader = message.envelopeReader;
message.envelopeReader = null;
SOAPVersion soapVersion = message.soapVersion;
// Move to soap:Envelope and verify
if (reader.getEventType() != XMLStreamConstants.START_ELEMENT)
XMLStreamReaderUtil.nextElementContent(reader);
XMLStreamReaderUtil.verifyReaderState(reader, XMLStreamConstants.START_ELEMENT);
if (SOAP_ENVELOPE.equals(reader.getLocalName()) && !soapVersion.nsUri.equals(reader.getNamespaceURI())) {
throw new VersionMismatchException(soapVersion, soapVersion.nsUri, reader.getNamespaceURI());
}
XMLStreamReaderUtil.verifyTag(reader, soapVersion.nsUri, SOAP_ENVELOPE);
TagInfoset envelopeTag = new TagInfoset(reader);
// Collect namespaces on soap:Envelope
Map<String, String> namespaces = new HashMap<>();
for (int i = 0; i < reader.getNamespaceCount(); i++) {
namespaces.put(reader.getNamespacePrefix(i), reader.getNamespaceURI(i));
}
// Move to next element
XMLStreamReaderUtil.nextElementContent(reader);
XMLStreamReaderUtil.verifyReaderState(reader, javax.xml.stream.XMLStreamConstants.START_ELEMENT);
HeaderList headers = null;
TagInfoset headerTag = null;
if (reader.getLocalName().equals(SOAP_HEADER) && reader.getNamespaceURI().equals(soapVersion.nsUri)) {
headerTag = new TagInfoset(reader);
// Collect namespaces on soap:Header
for (int i = 0; i < reader.getNamespaceCount(); i++) {
namespaces.put(reader.getNamespacePrefix(i), reader.getNamespaceURI(i));
}
// skip <soap:Header>
XMLStreamReaderUtil.nextElementContent(reader);
// If SOAP header blocks are present (i.e. not <soap:Header/>)
if (reader.getEventType() == XMLStreamConstants.START_ELEMENT) {
headers = new HeaderList(soapVersion);
try {
// Cache SOAP header blocks
StreamHeaderDecoder headerDecoder = SOAPVersion.SOAP_11.equals(soapVersion) ? SOAP11StreamHeaderDecoder : SOAP12StreamHeaderDecoder;
cacheHeaders(reader, namespaces, headers, headerDecoder);
} catch (XMLStreamException e) {
// TODO need to throw more meaningful exception
throw new WebServiceException(e);
}
}
// Move to soap:Body
XMLStreamReaderUtil.nextElementContent(reader);
}
// Verify that <soap:Body> is present
XMLStreamReaderUtil.verifyTag(reader, soapVersion.nsUri, SOAP_BODY);
TagInfoset bodyTag = new TagInfoset(reader);
String bodyPrologue = XMLStreamReaderUtil.nextWhiteSpaceContent(reader);
message.init(envelopeTag, headerTag, message.attachmentSet, headers, bodyPrologue, bodyTag, null, reader, soapVersion);
// when there's no payload,
// it's tempting to use EmptyMessageImpl, but it doesn't preserve the infoset
// of <envelope>,<header>, and <body>, so we need to stick to StreamMessage.
}
use of com.sun.xml.ws.api.SOAPVersion in project metro-jax-ws by eclipse-ee4j.
the class RuntimeModeler method createBinding.
/**
* creates a runtime model <code>SOAPBinding</code> from a <code>jakarta.jws.soap.SOAPBinding</code> object
* @param soapBinding the <code>jakarta.jws.soap.SOAPBinding</code> to model
* @return returns the runtime model SOAPBinding corresponding to <code>soapBinding</code>
*/
protected SOAPBindingImpl createBinding(SOAPBinding soapBinding) {
SOAPBindingImpl rtSOAPBinding = new SOAPBindingImpl();
Style style = soapBinding != null ? soapBinding.style() : Style.DOCUMENT;
rtSOAPBinding.setStyle(style);
assert bindingId != null;
model.bindingId = bindingId;
SOAPVersion soapVersion = bindingId.getSOAPVersion();
rtSOAPBinding.setSOAPVersion(soapVersion);
return rtSOAPBinding;
}
use of com.sun.xml.ws.api.SOAPVersion in project metro-jax-ws by eclipse-ee4j.
the class RuntimeModeler method getDefaultBindingID.
private BindingID getDefaultBindingID() {
BindingType bt = getAnnotation(portClass, BindingType.class);
if (bt != null)
return BindingID.parse(bt.value());
SOAPVersion ver = WebServiceFeatureList.getSoapVersion(features);
boolean mtomEnabled = features.isEnabled(MTOMFeature.class);
if (SOAPVersion.SOAP_12.equals(ver)) {
return (mtomEnabled) ? BindingID.SOAP12_HTTP_MTOM : BindingID.SOAP12_HTTP;
} else {
return (mtomEnabled) ? BindingID.SOAP11_HTTP_MTOM : BindingID.SOAP11_HTTP;
}
}
Aggregations