Search in sources :

Example 11 with MemberSubmissionAddressingFeature

use of com.sun.xml.ws.developer.MemberSubmissionAddressingFeature in project metro-jax-ws by eclipse-ee4j.

the class AddNumbersClient method testCustomFault.

/**
 * This test tests the functionality of OnewayFeature and AddressingFeature the way it being used in WS-AT implementation
 * In WS-AT impl, Server-side has to send fault messages to predefined coordinator and this test replicates that usage.
 *
 * @throws Exception
 */
public void testCustomFault() throws Exception {
    if (ClientServerTestUtil.useLocal()) {
        System.out.println("Only Testable in HTTP transport!");
        return;
    }
    SOAPFault fault = SOAPFactory.newInstance().createFault("custom fault from client", SOAPConstants.SOAP_SENDER_FAULT);
    InputStream is = getClass().getClassLoader().getResourceAsStream("wsa/fromwsdl/custom/config/AddNumbers.wsdl");
    assertNotNull("WSDL cannot be read", is);
    ArrayList<Element> metadata = new ArrayList<Element>();
    metadata.add((Element) DOMUtil.createDOMNode(is).getFirstChild());
    // WSEndpointReference to = new WSEndpointReference(AddressingVersion.W3C,
    // getAddress(),
    // SERVICE_QNAME,
    // PORT_QNAME,
    // PORT_TYPE_QNAME,
    // metadata,
    // getWsdlAddress(),
    // null);
    OneWayFeature owf = new OneWayFeature();
    owf.setRelatesToID("uuid:foobar");
    Service service = Service.create(SERVICE_QNAME);
    service.addPort(PORT_QNAME, SOAPBinding.SOAP11HTTP_BINDING, getAddress());
    // Dispatch<Source> dispatch = service.createDispatch(to.toSpec(), Source.class,
    // Service.Mode.PAYLOAD,
    // new AddressingFeature(true, true),
    // owf);
    Dispatch<Source> dispatch = service.createDispatch(PORT_QNAME, Source.class, Service.Mode.PAYLOAD, new MemberSubmissionAddressingFeature(true), owf);
    // Since this fault is not a wsdl operation, we need to set SOAPAction for correct wsa:Action
    dispatch.getRequestContext().put(BindingProvider.SOAPACTION_USE_PROPERTY, true);
    dispatch.getRequestContext().put(BindingProvider.SOAPACTION_URI_PROPERTY, "http://example.com/myfault");
    try {
        dispatch.invokeOneWay(new DOMSource(fault));
    } catch (WebServiceException e) {
    // since the server-side is not provider based for this test.
    // it does n't know from the fault message request that it is oneway and throws 500 code.
    // so, expect a WebServcieException here.
    }
// System.out.println(dispatch.getRequestContext().get(BindingProvider.ENDPOINT_ADDRESS_PROPERTY));
}
Also used : DOMSource(javax.xml.transform.dom.DOMSource) InputStream(java.io.InputStream) OneWayFeature(com.sun.xml.ws.api.addressing.OneWayFeature) Element(org.w3c.dom.Element) ArrayList(java.util.ArrayList) WSService(com.sun.xml.ws.api.WSService) SOAPFault(jakarta.xml.soap.SOAPFault) MemberSubmissionAddressingFeature(com.sun.xml.ws.developer.MemberSubmissionAddressingFeature) DOMSource(javax.xml.transform.dom.DOMSource) Source(javax.xml.transform.Source)

Example 12 with MemberSubmissionAddressingFeature

use of com.sun.xml.ws.developer.MemberSubmissionAddressingFeature in project metro-jax-ws by eclipse-ee4j.

the class AddNumbersClient method createDispatchWithWSDL.

private Dispatch<SOAPMessage> createDispatchWithWSDL() throws Exception {
    MemberSubmissionAddressingFeature msAddressingFeature = new MemberSubmissionAddressingFeature(true);
    RespectBindingFeature respectBindingFeature = new RespectBindingFeature(true);
    WebServiceFeature[] features = new WebServiceFeature[] { msAddressingFeature, respectBindingFeature };
    AddNumbersService service = new AddNumbersService();
    return service.createDispatch(PORT_QNAME, SOAPMessage.class, Service.Mode.MESSAGE);
}
Also used : RespectBindingFeature(jakarta.xml.ws.RespectBindingFeature) WebServiceFeature(jakarta.xml.ws.WebServiceFeature) MemberSubmissionAddressingFeature(com.sun.xml.ws.developer.MemberSubmissionAddressingFeature)

Example 13 with MemberSubmissionAddressingFeature

use of com.sun.xml.ws.developer.MemberSubmissionAddressingFeature in project metro-jax-ws by eclipse-ee4j.

the class AddNumbersClient method testReplyToRefpsWithWSDL.

public void testReplyToRefpsWithWSDL() throws Exception {
    MemberSubmissionAddressingFeature addressingFeature = new MemberSubmissionAddressingFeature(false);
    WebServiceFeature[] features = new WebServiceFeature[] { addressingFeature };
    Dispatch dispatch = createDispatchWithWSDL(features);
    BindingImpl binding = (BindingImpl) dispatch.getBinding();
    boolean enabled = AddressingVersion.isEnabled(binding);
    assertTrue(enabled);
    SOAPMessage response = WsaUtils.invoke(dispatch, WsaUtils.REPLY_TO_REFPS_MESSAGE, WsaUtils.S11_NS, WsaUtils.W3C_WSA_NS, getAddress(), W3CAddressingConstants.WSA_ANONYMOUS_ADDRESS, CORRECT_ACTION);
    ByteArrayOutputStream baos = new ByteArrayOutputStream();
    response.writeTo(baos);
    assertXpathExists(REPLY_TO_REFPS, baos.toString());
    assertXpathEvaluatesTo(REPLY_TO_REFPS_VALUE, baos.toString(), "Key#123456789");
    assertXpathExists(REPLY_TO_REFPS_ISREFP, baos.toString());
}
Also used : BindingImpl(com.sun.xml.ws.binding.BindingImpl) WebServiceFeature(jakarta.xml.ws.WebServiceFeature) Dispatch(jakarta.xml.ws.Dispatch) ByteArrayOutputStream(java.io.ByteArrayOutputStream) MemberSubmissionAddressingFeature(com.sun.xml.ws.developer.MemberSubmissionAddressingFeature) SOAPMessage(jakarta.xml.soap.SOAPMessage)

Example 14 with MemberSubmissionAddressingFeature

use of com.sun.xml.ws.developer.MemberSubmissionAddressingFeature in project metro-jax-ws by eclipse-ee4j.

the class AddNumbersClient method testEPRGetPortVIIIII.

// UsingAddressing wsdl:required=true
// AddressingFeature Disabled expect Exception
// Expect no valid port created, so exception thrown
public void testEPRGetPortVIIIII() throws Exception {
    if (ClientServerTestUtil.useLocal()) {
        System.out.println("HTTP Transport Only Exiting");
        return;
    }
    AddNumbersPortType proxy = createStub();
    EndpointReference epr = ((BindingProvider) proxy).getEndpointReference(MemberSubmissionEndpointReference.class);
    RespectBindingFeature feature = new RespectBindingFeature(true);
    MemberSubmissionAddressingFeature addr = new MemberSubmissionAddressingFeature(true, true);
    WebServiceFeature[] features = new WebServiceFeature[] { feature, addr };
    AddNumbersPortType port = epr.getPort(AddNumbersPortType.class, features);
    assertTrue(port != null);
    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 : 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 15 with MemberSubmissionAddressingFeature

use of com.sun.xml.ws.developer.MemberSubmissionAddressingFeature in project metro-jax-ws by eclipse-ee4j.

the class MemberSubmissionAddressingWSDLParserExtension method addressibleElement.

private boolean addressibleElement(XMLStreamReader reader, WSDLFeaturedObject binding) {
    QName ua = reader.getName();
    if (ua.equals(AddressingVersion.MEMBER.wsdlExtensionTag)) {
        String required = reader.getAttributeValue(WSDLConstants.NS_WSDL, "required");
        binding.addFeature(new MemberSubmissionAddressingFeature(Boolean.parseBoolean(required)));
        XMLStreamReaderUtil.skipElement(reader);
        // UsingAddressing is consumed
        return true;
    }
    return false;
}
Also used : QName(javax.xml.namespace.QName) MemberSubmissionAddressingFeature(com.sun.xml.ws.developer.MemberSubmissionAddressingFeature)

Aggregations

MemberSubmissionAddressingFeature (com.sun.xml.ws.developer.MemberSubmissionAddressingFeature)19 MemberSubmissionEndpointReference (com.sun.xml.ws.developer.MemberSubmissionEndpointReference)9 W3CEndpointReference (jakarta.xml.ws.wsaddressing.W3CEndpointReference)9 WSEndpointReference (com.sun.xml.ws.api.addressing.WSEndpointReference)6 SOAPFaultException (jakarta.xml.ws.soap.SOAPFaultException)4 WebServiceFeature (jakarta.xml.ws.WebServiceFeature)3 WSService (com.sun.xml.ws.api.WSService)2 OneWayFeature (com.sun.xml.ws.api.addressing.OneWayFeature)2 BindingImpl (com.sun.xml.ws.binding.BindingImpl)2 SOAPFault (jakarta.xml.soap.SOAPFault)2 Dispatch (jakarta.xml.ws.Dispatch)2 RespectBindingFeature (jakarta.xml.ws.RespectBindingFeature)2 AddressingFeature (jakarta.xml.ws.soap.AddressingFeature)2 Source (javax.xml.transform.Source)2 DOMSource (javax.xml.transform.dom.DOMSource)2 SOAPMessage (jakarta.xml.soap.SOAPMessage)1 ByteArrayOutputStream (java.io.ByteArrayOutputStream)1 IOException (java.io.IOException)1 InputStream (java.io.InputStream)1 ArrayList (java.util.ArrayList)1