Search in sources :

Example 71 with BindingProvider

use of jakarta.xml.ws.BindingProvider 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 72 with BindingProvider

use of jakarta.xml.ws.BindingProvider 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)

Example 73 with BindingProvider

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

the class HostIgnoreCaseTest method test3.

/*
     * With maintain property set to true, session
     * should be maintained.
     */
public void test3() throws Exception {
    Hello proxy = new HelloService().getHelloPort();
    // Set the adress with upper case hostname
    Map<String, Object> requestContext = ((BindingProvider) proxy).getRequestContext();
    requestContext.put(BindingProvider.SESSION_MAINTAIN_PROPERTY, Boolean.TRUE);
    // proxy.introduce(); Doing this below as setting endpoint address
    // resets the cookie store. Will be handled in future revisions
    String addr = (String) requestContext.get(BindingProvider.ENDPOINT_ADDRESS_PROPERTY);
    URL url = new URL(addr);
    String host = url.getHost();
    addr = addr.replace(host, host.toUpperCase());
    requestContext.put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY, addr);
    proxy.introduce();
    assertTrue("client session should be maintained", proxy.rememberMe());
}
Also used : BindingProvider(jakarta.xml.ws.BindingProvider) URL(java.net.URL)

Example 74 with BindingProvider

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

the class HostIgnoreCaseTest method test3.

/*
     * With maintain property set to true, session
     * should be maintained.
     */
public void test3() throws Exception {
    Hello proxy = new HelloService().getHelloPort();
    // Set the adress with upper case hostname
    Map<String, Object> requestContext = ((BindingProvider) proxy).getRequestContext();
    requestContext.put(BindingProvider.SESSION_MAINTAIN_PROPERTY, Boolean.TRUE);
    proxy.introduce();
    String addr = (String) requestContext.get(BindingProvider.ENDPOINT_ADDRESS_PROPERTY);
    URL url = new URL(addr);
    String host = url.getHost();
    addr = addr.replace(host, host.toUpperCase());
    requestContext.put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY, addr);
    assertTrue("client session should be maintained", proxy.rememberMe());
}
Also used : BindingProvider(jakarta.xml.ws.BindingProvider) URL(java.net.URL)

Example 75 with BindingProvider

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

the class SOAPActionTest method testUnquotedSOAPAction2.

public void testUnquotedSOAPAction2() throws Exception {
    TestEndpoint port = new TestEndpointService().getTestEndpointPort1();
    String address = (String) ((BindingProvider) port).getRequestContext().get(BindingProvider.ENDPOINT_ADDRESS_PROPERTY);
    HTTPResponseInfo rInfo = ClientServerTestUtil.sendPOSTRequest(address, s11_request, "text/xml", "http://example.com/action/echo1");
    String resp = rInfo.getResponseBody();
    SOAPMessage respMesg = getSOAPMessage(makeStreamSource(resp));
    SOAPBody body = respMesg.getSOAPPart().getEnvelope().getBody();
    Element e = (Element) body.getElementsByTagName("return").item(0);
    // make sure it is dispatched to echo1() using SoapAction
    assertEquals("Hello1 Duke", e.getTextContent());
}
Also used : SOAPBody(jakarta.xml.soap.SOAPBody) Element(org.w3c.dom.Element) BindingProvider(jakarta.xml.ws.BindingProvider) HTTPResponseInfo(testutil.HTTPResponseInfo) SOAPMessage(jakarta.xml.soap.SOAPMessage)

Aggregations

BindingProvider (jakarta.xml.ws.BindingProvider)75 Binding (jakarta.xml.ws.Binding)32 Handler (jakarta.xml.ws.handler.Handler)28 Service (jakarta.xml.ws.Service)17 SOAPBinding (jakarta.xml.ws.soap.SOAPBinding)17 QName (javax.xml.namespace.QName)16 URL (java.net.URL)9 ArrayList (java.util.ArrayList)8 Source (javax.xml.transform.Source)8 SOAPMessage (jakarta.xml.soap.SOAPMessage)7 MTOMFeature (jakarta.xml.ws.soap.MTOMFeature)7 List (java.util.List)6 Map (java.util.Map)6 SOAPTestHandler (fromwsdl.handler_simple.common.SOAPTestHandler)5 JAXBElement (jakarta.xml.bind.JAXBElement)5 ByteArrayInputStream (java.io.ByteArrayInputStream)5 StreamSource (javax.xml.transform.stream.StreamSource)5 SOAPTestHandler (fromwsdl.handler_simple_rpclit.common.SOAPTestHandler)4 MimeHeaders (jakarta.xml.soap.MimeHeaders)4 WebServiceException (jakarta.xml.ws.WebServiceException)4