Search in sources :

Example 21 with AddressingFeature

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

the class AddNumbersClient method testEPRGetPortV.

// UsingAddressing wsdl:required=true
// AddressingFeature Disabled expect Exception
// Expect no valid addressingport created, so exception thrown
public void testEPRGetPortV() throws Exception {
    if (ClientServerTestUtil.useLocal()) {
        System.out.println("HTTP Transport Only Exiting");
        return;
    }
    AddNumbersPortType proxy = createStub();
    // EndpointReference epr = ((BindingProvider) proxy).getEndpointReference(W3CEndpointReference.class);
    EndpointReference epr = ((BindingProvider) proxy).getEndpointReference(MemberSubmissionEndpointReference.class);
    // force addressing off
    AddressingFeature feature = new AddressingFeature(false, false);
    WebServiceFeature[] features = new WebServiceFeature[] { feature };
    AddNumbersPortType port = epr.getPort(AddNumbersPortType.class, features);
    assertTrue(port != null);
    // expectation is that port is not configured for addressing and the invocation will fail
    try {
        System.out.println("Adding numbers 2 and 4");
        int result = port.addNumbers(2, 4);
    } catch (Exception ex) {
        assertTrue(ex instanceof SOAPFaultException);
        System.out.println(((SOAPFaultException) ex).getFault().getFaultString());
    }
}
Also used : AddressingFeature(jakarta.xml.ws.soap.AddressingFeature) MemberSubmissionAddressingFeature(com.sun.xml.ws.developer.MemberSubmissionAddressingFeature) SOAPFaultException(jakarta.xml.ws.soap.SOAPFaultException) IOException(java.io.IOException) SOAPFaultException(jakarta.xml.ws.soap.SOAPFaultException) W3CEndpointReference(jakarta.xml.ws.wsaddressing.W3CEndpointReference) WSEndpointReference(com.sun.xml.ws.api.addressing.WSEndpointReference) MemberSubmissionEndpointReference(com.sun.xml.ws.developer.MemberSubmissionEndpointReference)

Example 22 with AddressingFeature

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

the class AddNumbersClient method testEPRGetPortVIIII.

// UsingAddressing wsdl:required=true
// AddressingFeature Disabled expect Exception
// Expect no valid port created, so exception thrown
public void testEPRGetPortVIIII() throws Exception {
    if (ClientServerTestUtil.useLocal()) {
        System.out.println("HTTP Transport Only Exiting");
        return;
    }
    AddNumbersPortType proxy = createStub();
    // EndpointReference epr = ((BindingProvider) proxy).getEndpointReference(W3CEndpointReference.class);
    EndpointReference epr = ((BindingProvider) proxy).getEndpointReference(MemberSubmissionEndpointReference.class);
    RespectBindingFeature feature = new RespectBindingFeature(true);
    AddressingFeature addr = new AddressingFeature(true, false);
    WebServiceFeature[] features = new WebServiceFeature[] { feature, addr };
    AddNumbersPortType port = epr.getPort(AddNumbersPortType.class, features);
    assertTrue(port != null);
    // expectation is that port is not configured for addressing and the invocation will fail
    try {
        System.out.println("Adding numbers 2 and 4");
        int result = port.addNumbers(2, 4);
    } catch (Exception ex) {
        assertTrue(ex instanceof SOAPFaultException);
        System.out.println(((SOAPFaultException) ex).getFault().getFaultString());
    }
}
Also used : AddressingFeature(jakarta.xml.ws.soap.AddressingFeature) MemberSubmissionAddressingFeature(com.sun.xml.ws.developer.MemberSubmissionAddressingFeature) SOAPFaultException(jakarta.xml.ws.soap.SOAPFaultException) IOException(java.io.IOException) SOAPFaultException(jakarta.xml.ws.soap.SOAPFaultException) W3CEndpointReference(jakarta.xml.ws.wsaddressing.W3CEndpointReference) WSEndpointReference(com.sun.xml.ws.api.addressing.WSEndpointReference) MemberSubmissionEndpointReference(com.sun.xml.ws.developer.MemberSubmissionEndpointReference)

Example 23 with AddressingFeature

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

the class AddNumbersClient method testDispatchWithRefParams.

public void testDispatchWithRefParams() throws Exception {
    if (ClientServerTestUtil.useLocal()) {
        System.out.println("HTTP Transport Only Exiting");
        return;
    }
    String xmlRefParam1 = "<myns1:MyParam1 xmlns:myns1=\"http://cptestservice.org/wsdl\">Hello</myns1:MyParam1>";
    String xmlRefParam2 = "<myns2:MyParam2 xmlns:myns2=\"http://cptestservice.org/wsdl\">There</myns2:MyParam2>";
    String request = "<?xml version=\"1.0\" ?><S:Envelope xmlns:S=\"http://schemas.xmlsoap.org/soap/envelope/\"><S:Body><DataType xmlns=\"http://cptestservice.org/xsd\"><param>{0}</param></DataType></S:Body></S:Envelope>";
    // W3CEndpointReferenceBuilder eprBuilder = new W3CEndpointReferenceBuilder();
    // eprBuilder.address(ENDPOINT_ADDRESS);
    // eprBuilder.serviceName(SERVICE_QNAME);
    // eprBuilder.endpointName(PORT_QNAME);
    List<Element> refParams = new ArrayList<Element>();
    Element n1 = (Element) DOMUtil.createDOMNode(new ByteArrayInputStream(xmlRefParam1.getBytes())).getFirstChild();
    Element n2 = (Element) DOMUtil.createDOMNode(new ByteArrayInputStream(xmlRefParam2.getBytes())).getFirstChild();
    refParams.add(n1);
    refParams.add(n2);
    // eprBuilder.referenceParameter(n1);
    // eprBuilder.referenceParameter(n2);
    // W3CEndpointReference epr = eprBuilder.build();
    WSEndpointReference wsepr = new WSEndpointReference(AddressingVersion.MEMBER, ENDPOINT_ADDRESS, SERVICE_QNAME, PORT_QNAME, null, null, null, refParams);
    MemberSubmissionEndpointReference epr = wsepr.toSpec(MemberSubmissionEndpointReference.class);
    printEPR(epr);
    URL fakeWsdlUrl = Thread.currentThread().getContextClassLoader().getResource("wsdl/AddNumbersFake.wsdl");
    Service service = Service.create(fakeWsdlUrl, SERVICE_QNAME);
    JAXBContext jc = createJAXBContext();
    Dispatch<Object> dispatch = service.createDispatch(epr, jc, Service.Mode.PAYLOAD, new AddressingFeature());
    AddNumbers input = new AddNumbers();
    input.setNumber1(2);
    input.setNumber2(4);
    JAXBElement<AddNumbersResponse> o = (JAXBElement<AddNumbersResponse>) dispatch.invoke(new ObjectFactory().createAddNumbers(input));
    int result = o.getValue().getReturn();
    assert (result == 6);
}
Also used : AddressingFeature(jakarta.xml.ws.soap.AddressingFeature) MemberSubmissionAddressingFeature(com.sun.xml.ws.developer.MemberSubmissionAddressingFeature) Element(org.w3c.dom.Element) JAXBElement(jakarta.xml.bind.JAXBElement) ArrayList(java.util.ArrayList) JAXBContext(jakarta.xml.bind.JAXBContext) JAXBElement(jakarta.xml.bind.JAXBElement) URL(java.net.URL) ByteArrayInputStream(java.io.ByteArrayInputStream) WSEndpointReference(com.sun.xml.ws.api.addressing.WSEndpointReference) MemberSubmissionEndpointReference(com.sun.xml.ws.developer.MemberSubmissionEndpointReference)

Example 24 with AddressingFeature

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

the class AddNumbersClient method testEPRGetPortIV.

// UsingAddressing wsdl:required=true
// AddressingFeature Disabled expect Exception
// Expect no valid port created, so exception thrown
public void testEPRGetPortIV() throws Exception {
    if (ClientServerTestUtil.useLocal()) {
        System.out.println("HTTP Transport Only Exiting");
        return;
    }
    AddNumbersPortType proxy = createStub();
    EndpointReference epr = ((BindingProvider) proxy).getEndpointReference(MemberSubmissionEndpointReference.class);
    // force addressing off
    AddressingFeature feature = new AddressingFeature(false, false);
    WebServiceFeature[] features = new WebServiceFeature[] { feature };
    AddNumbersPortType port = epr.getPort(AddNumbersPortType.class, features);
    assertTrue(port != null);
    // expectation is that port is not configured for addressing and the invocation will fail
    try {
        System.out.println("Adding numbers 2 and 4");
        int result = port.addNumbers(2, 4);
    } catch (Exception ex) {
        assertTrue(ex instanceof SOAPFaultException);
        System.out.println(((SOAPFaultException) ex).getFault().getFaultString());
    }
}
Also used : AddressingFeature(jakarta.xml.ws.soap.AddressingFeature) MemberSubmissionAddressingFeature(com.sun.xml.ws.developer.MemberSubmissionAddressingFeature) SOAPFaultException(jakarta.xml.ws.soap.SOAPFaultException) IOException(java.io.IOException) SOAPFaultException(jakarta.xml.ws.soap.SOAPFaultException) W3CEndpointReference(jakarta.xml.ws.wsaddressing.W3CEndpointReference) WSEndpointReference(com.sun.xml.ws.api.addressing.WSEndpointReference) MemberSubmissionEndpointReference(com.sun.xml.ws.developer.MemberSubmissionEndpointReference)

Example 25 with AddressingFeature

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

the class AddNumbersClient method testEPRGetPortVII.

// UsingAddressing wsdl:required=true
// AddressingFeature Disabled expect Exception
// Expect no valid port created, so exception thrown
public void testEPRGetPortVII() throws Exception {
    if (ClientServerTestUtil.useLocal()) {
        System.out.println("HTTP Transport Only Exiting");
        return;
    }
    AddNumbersPortType proxy = createStub();
    // EndpointReference epr = ((BindingProvider) proxy).getEndpointReference(W3CEndpointReference.class);
    EndpointReference epr = ((BindingProvider) proxy).getEndpointReference(MemberSubmissionEndpointReference.class);
    RespectBindingFeature feature = new RespectBindingFeature(true);
    AddressingFeature addr = new AddressingFeature(false, false);
    WebServiceFeature[] features = new WebServiceFeature[] { feature, addr };
    AddNumbersPortType port = epr.getPort(AddNumbersPortType.class, features);
    assertTrue(port != null);
    // expectation is that port is not configured for addressing and the invocation will fail
    try {
        System.out.println("Adding numbers 2 and 4");
        int result = port.addNumbers(2, 4);
    } catch (Exception ex) {
        assertTrue(ex instanceof SOAPFaultException);
        System.out.println(((SOAPFaultException) ex).getFault().getFaultString());
    }
}
Also used : AddressingFeature(jakarta.xml.ws.soap.AddressingFeature) MemberSubmissionAddressingFeature(com.sun.xml.ws.developer.MemberSubmissionAddressingFeature) SOAPFaultException(jakarta.xml.ws.soap.SOAPFaultException) IOException(java.io.IOException) SOAPFaultException(jakarta.xml.ws.soap.SOAPFaultException) W3CEndpointReference(jakarta.xml.ws.wsaddressing.W3CEndpointReference) WSEndpointReference(com.sun.xml.ws.api.addressing.WSEndpointReference) MemberSubmissionEndpointReference(com.sun.xml.ws.developer.MemberSubmissionEndpointReference)

Aggregations

AddressingFeature (jakarta.xml.ws.soap.AddressingFeature)41 MemberSubmissionAddressingFeature (com.sun.xml.ws.developer.MemberSubmissionAddressingFeature)21 MemberSubmissionEndpointReference (com.sun.xml.ws.developer.MemberSubmissionEndpointReference)17 W3CEndpointReference (jakarta.xml.ws.wsaddressing.W3CEndpointReference)16 SOAPFaultException (jakarta.xml.ws.soap.SOAPFaultException)11 WSEndpointReference (com.sun.xml.ws.api.addressing.WSEndpointReference)10 QName (javax.xml.namespace.QName)7 JAXBElement (jakarta.xml.bind.JAXBElement)5 Service (jakarta.xml.ws.Service)5 SOAPMessage (jakarta.xml.soap.SOAPMessage)4 IOException (java.io.IOException)4 BindingImpl (com.sun.xml.ws.binding.BindingImpl)3 JAXBContext (jakarta.xml.bind.JAXBContext)3 BindingProvider (jakarta.xml.ws.BindingProvider)3 Endpoint (jakarta.xml.ws.Endpoint)3 WebServiceFeature (jakarta.xml.ws.WebServiceFeature)3 URL (java.net.URL)3 ArrayList (java.util.ArrayList)3 WSBinding (com.sun.xml.ws.api.WSBinding)2 AssertionSet (com.sun.xml.ws.policy.AssertionSet)2