Search in sources :

Example 1 with BindingProvider

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

the class AddNumbersTest method testSuccess.

@Test
public void testSuccess() throws AddNumbersException_Exception {
    AddNumbers port = new AddNumbersImplService().getAddNumbersImplPort();
    Map<String, Object> ctxt = ((BindingProvider) port).getRequestContext();
    int number1 = 10;
    int number2 = 20;
    System.out.printf("Invoking addNumbers(%d, %d)\n", number1, number2);
    int result = port.add(number1, number2);
    System.out.printf("The result of adding %d and %d is %d.\n\n", number1, number2, result);
    Assertions.assertEquals(30, result);
}
Also used : AddNumbersImplService(annotations.client.AddNumbersImplService) AddNumbers(annotations.client.AddNumbers) BindingProvider(jakarta.xml.ws.BindingProvider) Test(org.junit.jupiter.api.Test)

Example 2 with BindingProvider

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

the class MtomTest method testMtom.

// test for WSIT 1069, makes sure Mtom is enabled and this happens when the WSDL has the necessary policy assertion.
public void testMtom() throws Exception {
    MtomSample proxy = new MtomSampleService().getMtomSamplePort();
    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);
    assertTrue(s.startsWith("multipart/related"));
    assertTrue(s.contains("type=\"application/xop+xml\""));
}
Also used : 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 3 with BindingProvider

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

the class OnewayTest method getHttpStatus.

private int getHttpStatus(String address) throws Exception {
    QName portName = new QName(NS, "OnewayEndpointPort");
    QName serviceName = new QName(NS, "OnewayEndpointService");
    Service service = Service.create(new URL(address + "?wsdl"), serviceName);
    Dispatch<Source> d = service.createDispatch(portName, Source.class, Service.Mode.PAYLOAD);
    String body = "<ns0:echoInteger xmlns:ns0='" + NS + "'><arg0>12345</arg0></ns0:echoInteger>";
    d.invokeOneWay(new StreamSource(new StringReader(body)));
    Map<String, Object> rc = ((BindingProvider) d).getResponseContext();
    return (Integer) rc.get(MessageContext.HTTP_RESPONSE_CODE);
}
Also used : QName(javax.xml.namespace.QName) StreamSource(javax.xml.transform.stream.StreamSource) StringReader(java.io.StringReader) Service(jakarta.xml.ws.Service) WebService(jakarta.jws.WebService) BindingProvider(jakarta.xml.ws.BindingProvider) URL(java.net.URL) StreamSource(javax.xml.transform.stream.StreamSource) Source(javax.xml.transform.Source)

Example 4 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();
    Map<String, Object> requestContext = ((BindingProvider) proxy).getRequestContext();
    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);
    requestContext.put(BindingProvider.SESSION_MAINTAIN_PROPERTY, Boolean.TRUE);
    proxy.introduce();
    assertTrue("client session should be maintained", proxy.rememberMe());
}
Also used : BindingProvider(jakarta.xml.ws.BindingProvider) URL(java.net.URL)

Example 5 with BindingProvider

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

the class SOAPActionTest method testUnquotedSOAPAction1.

public void testUnquotedSOAPAction1() 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/echo");
    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 echo() using SoapAction
    assertEquals("Hello 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)74 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 MTOMFeature (jakarta.xml.ws.soap.MTOMFeature)7 Source (javax.xml.transform.Source)7 JAXBElement (jakarta.xml.bind.JAXBElement)6 SOAPMessage (jakarta.xml.soap.SOAPMessage)6 List (java.util.List)6 Map (java.util.Map)6 SOAPTestHandler (fromwsdl.handler_simple.common.SOAPTestHandler)5 ByteArrayInputStream (java.io.ByteArrayInputStream)5 SOAPTestHandler (fromwsdl.handler_simple_rpclit.common.SOAPTestHandler)4 MimeHeaders (jakarta.xml.soap.MimeHeaders)4 WebServiceException (jakarta.xml.ws.WebServiceException)4 StreamSource (javax.xml.transform.stream.StreamSource)4