Search in sources :

Example 21 with MTOMFeature

use of jakarta.xml.ws.soap.MTOMFeature in project metro-jax-ws by eclipse-ee4j.

the class MtomTest method testMtomOptionality.

// test for WSIT 1062
public void testMtomOptionality() throws Exception {
    MtomSample proxy = new MtomSampleService().getMtomSamplePort(new MTOMFeature(false));
    Source output = proxy.echo(getSource("sample_doc.xml"));
    Map<String, List<String>> response_headers = (Map<String, List<String>>) ((BindingProvider) proxy).getResponseContext().get(MessageContext.HTTP_RESPONSE_HEADERS);
    String s = response_headers.get("Content-Type").get(0);
    System.out.println(s);
    assertTrue(s.startsWith("application/soap+xml"));
    assertTrue(!s.contains("type=\"application/xop+xml\""));
}
Also used : MTOMFeature(jakarta.xml.ws.soap.MTOMFeature) List(java.util.List) BindingProvider(jakarta.xml.ws.BindingProvider) Map(java.util.Map) StreamSource(javax.xml.transform.stream.StreamSource) Source(javax.xml.transform.Source)

Example 22 with MTOMFeature

use of jakarta.xml.ws.soap.MTOMFeature in project metro-jax-ws by eclipse-ee4j.

the class MtomTest method testMtomPolicyOptionality.

// test for WSIT 1062, testing wsp:Optional="true" in the wsdl
public void testMtomPolicyOptionality() throws Exception {
    MtomSample proxy = new MtomSampleService().getMtomSamplePort(new MTOMFeature(false));
    String address = (String) ((BindingProvider) proxy).getRequestContext().get(BindingProvider.ENDPOINT_ADDRESS_PROPERTY);
    DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
    dbf.setNamespaceAware(true);
    DocumentBuilder db = dbf.newDocumentBuilder();
    Document wsdl = db.parse(address + "?wsdl");
    Element el = (Element) wsdl.getElementsByTagNameNS("http://schemas.xmlsoap.org/ws/2004/09/policy/optimizedmimeserialization", "OptimizedMimeSerialization").item(0);
    String optional = el.getAttributeNS("http://www.w3.org/ns/ws-policy", "Optional");
    assertTrue(Boolean.valueOf(optional));
}
Also used : DocumentBuilderFactory(javax.xml.parsers.DocumentBuilderFactory) DocumentBuilder(javax.xml.parsers.DocumentBuilder) MTOMFeature(jakarta.xml.ws.soap.MTOMFeature) Element(org.w3c.dom.Element) BindingProvider(jakarta.xml.ws.BindingProvider) Document(org.w3c.dom.Document)

Aggregations

MTOMFeature (jakarta.xml.ws.soap.MTOMFeature)22 BindingProvider (jakarta.xml.ws.BindingProvider)7 WebServiceFeature (jakarta.xml.ws.WebServiceFeature)5 SOAPMessage (jakarta.xml.soap.SOAPMessage)4 ByteArrayInputStream (java.io.ByteArrayInputStream)4 ByteArrayOutputStream (java.io.ByteArrayOutputStream)4 IOException (java.io.IOException)4 MessageContextFactory (com.oracle.webservices.api.message.MessageContextFactory)3 Message (com.sun.xml.ws.api.message.Message)3 Packet (com.sun.xml.ws.api.message.Packet)3 DataHandler (jakarta.activation.DataHandler)3 AttachmentPart (jakarta.xml.soap.AttachmentPart)3 MessageFactory (jakarta.xml.soap.MessageFactory)3 MimeHeaders (jakarta.xml.soap.MimeHeaders)3 InputStream (java.io.InputStream)3 QName (javax.xml.namespace.QName)3 MessageContext (com.oracle.webservices.api.message.MessageContext)2 BindingID (com.sun.xml.ws.api.BindingID)2 ImpliesWebServiceFeature (com.sun.xml.ws.api.ImpliesWebServiceFeature)2 StreamingDataHandler (com.sun.xml.ws.developer.StreamingDataHandler)2