Search in sources :

Example 26 with AddressingFeature

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

the class AddNumbersClient method testDispatchWithEPRAddress.

/**
 * In this testcase, the Service instance is created with a
 * fake wsdl (incorrect endpoint adress). Normal invocation would have failed.
 * But the Dispatch is created with EPR which has valid endpoint address.
 * So, epr address shoudl take precedence and invocation should succeed.
 */
public void testDispatchWithEPRAddress() throws Exception {
    if (ClientServerTestUtil.useLocal()) {
        System.out.println("HTTP Transport Only Exiting");
        return;
    }
    // W3CEndpointReferenceBuilder eprBuilder = new W3CEndpointReferenceBuilder();
    // eprBuilder.address(ENDPOINT_ADDRESS);
    // eprBuilder.serviceName(SERVICE_QNAME);
    // eprBuilder.endpointName(PORT_QNAME);
    // W3CEndpointReference epr = eprBuilder.build();
    WSEndpointReference wsepr = new WSEndpointReference(AddressingVersion.MEMBER, ENDPOINT_ADDRESS, SERVICE_QNAME, PORT_QNAME, null, null, null, null);
    MemberSubmissionEndpointReference epr = wsepr.toSpec(MemberSubmissionEndpointReference.class);
    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) JAXBContext(jakarta.xml.bind.JAXBContext) JAXBElement(jakarta.xml.bind.JAXBElement) URL(java.net.URL) WSEndpointReference(com.sun.xml.ws.api.addressing.WSEndpointReference) MemberSubmissionEndpointReference(com.sun.xml.ws.developer.MemberSubmissionEndpointReference)

Example 27 with AddressingFeature

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

the class AddNumbersClient method testEPRGetPortVIIIIII.

// UsingAddressing wsdl:required=true
// AddressingFeature Disabled expect Exception
// Expect no valid port created, so exception thrown
public void testEPRGetPortVIIIIII() 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, true);
    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
    System.out.println("Adding numbers 2 and 4");
    int result = port.addNumbers(2, 4);
    assert (result == 6);
    System.out.println("Addinion of 2 and 4 successful");
}
Also used : AddressingFeature(jakarta.xml.ws.soap.AddressingFeature) MemberSubmissionAddressingFeature(com.sun.xml.ws.developer.MemberSubmissionAddressingFeature) W3CEndpointReference(jakarta.xml.ws.wsaddressing.W3CEndpointReference) WSEndpointReference(com.sun.xml.ws.api.addressing.WSEndpointReference) MemberSubmissionEndpointReference(com.sun.xml.ws.developer.MemberSubmissionEndpointReference)

Example 28 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) SOAPFaultException(jakarta.xml.ws.soap.SOAPFaultException) W3CEndpointReference(jakarta.xml.ws.wsaddressing.W3CEndpointReference) MemberSubmissionEndpointReference(com.sun.xml.ws.developer.MemberSubmissionEndpointReference)

Example 29 with AddressingFeature

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

the class AddNumbersClient method testEPRGetPortV.

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) SOAPFaultException(jakarta.xml.ws.soap.SOAPFaultException) W3CEndpointReference(jakarta.xml.ws.wsaddressing.W3CEndpointReference) MemberSubmissionEndpointReference(com.sun.xml.ws.developer.MemberSubmissionEndpointReference)

Example 30 with AddressingFeature

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

the class AddNumbersClient method testEPRGetPortVIIIIII.

public void testEPRGetPortVIIIIII() 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, true);
    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
    System.out.println("Adding numbers 2 and 4");
    int result = port.addNumbers(2, 4);
    assert (result == 6);
    System.out.println("Addinion of 2 and 4 successful");
}
Also used : AddressingFeature(jakarta.xml.ws.soap.AddressingFeature) MemberSubmissionAddressingFeature(com.sun.xml.ws.developer.MemberSubmissionAddressingFeature) W3CEndpointReference(jakarta.xml.ws.wsaddressing.W3CEndpointReference) 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