Search in sources :

Example 11 with MemberSubmissionEndpointReference

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

the class EndpointEPRTester method testMSEPR.

public void testMSEPR() throws Exception {
    int port = Util.getFreePort();
    String address = "http://localhost:" + port + "/hello";
    Endpoint endpoint = Endpoint.create(new RpcLitEndpoint());
    List<Source> metadata = new ArrayList<Source>();
    ClassLoader cl = Thread.currentThread().getContextClassLoader();
    String[] docs = { "WEB-INF/wsdl/RpcLitEndpoint.wsdl", "WEB-INF/wsdl/RpcLitAbstract.wsdl", "WEB-INF/wsdl/RpcLitEndpoint.xsd" };
    for (String doc : docs) {
        URL url = cl.getResource(doc);
        metadata.add(new StreamSource(url.openStream(), url.toExternalForm()));
    }
    endpoint.setMetadata(metadata);
    endpoint.publish(address);
    MemberSubmissionEndpointReference epr = endpoint.getEndpointReference(MemberSubmissionEndpointReference.class);
    endpoint.stop();
    EprUtil.validateEPR(epr, address, serviceName, portName, portTypeName, Boolean.TRUE);
    printEPR(epr);
}
Also used : Endpoint(jakarta.xml.ws.Endpoint) StreamSource(javax.xml.transform.stream.StreamSource) ArrayList(java.util.ArrayList) MemberSubmissionEndpointReference(com.sun.xml.ws.developer.MemberSubmissionEndpointReference) Endpoint(jakarta.xml.ws.Endpoint) StreamSource(javax.xml.transform.stream.StreamSource) Source(javax.xml.transform.Source) URL(java.net.URL)

Example 12 with MemberSubmissionEndpointReference

use of com.sun.xml.ws.developer.MemberSubmissionEndpointReference 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 13 with MemberSubmissionEndpointReference

use of com.sun.xml.ws.developer.MemberSubmissionEndpointReference 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 14 with MemberSubmissionEndpointReference

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

the class AddNumbersClient method testCreateDispatchJAXBMSEPRNoPortQName.

// UsingAddressing wsdl:required=true
// RespectBindingFeature Disabled - no effect - behavior undefined by specification
// for backward compatability
public void testCreateDispatchJAXBMSEPRNoPortQName() throws Exception {
    if (ClientServerTestUtil.useLocal()) {
        System.out.println("HTTP Transport Only Exiting");
        return;
    }
    RespectBindingFeature rbf = new RespectBindingFeature(true);
    WebServiceFeature[] wse = new WebServiceFeature[] { rbf };
    Service service = createServiceWithWSDL();
    MemberSubmissionEndpointReference msEPR = createMSEPRStubServiceWithWSDL(service);
    msEPR.portTypeName.name = null;
    MSEPRString = msEPR.toString();
    Dispatch<Object> dispatch = service.createDispatch(EndpointReference.readFrom(makeStreamSource(MSEPRString)), createJAXBContext(), Service.Mode.PAYLOAD, wse);
    AddNumbers addNumbers = factory.createAddNumbers();
    addNumbers.setNumber1(2);
    addNumbers.setNumber2(4);
    JAXBElement<AddNumbers> num = factory.createAddNumbers(addNumbers);
    JAXBElement<AddNumbersResponse> addNumbersResponse = (JAXBElement<AddNumbersResponse>) dispatch.invoke(num);
    AddNumbersResponse response = addNumbersResponse.getValue();
    assertEquals(response.getReturn(), 2 + 4);
}
Also used : JAXBElement(jakarta.xml.bind.JAXBElement) MemberSubmissionEndpointReference(com.sun.xml.ws.developer.MemberSubmissionEndpointReference)

Example 15 with MemberSubmissionEndpointReference

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

the class AddNumbersClient method testCreateDispatchSourceMSEPRNoPortQName.

// UsingAddressing wsdl:required=true
public void testCreateDispatchSourceMSEPRNoPortQName() throws Exception {
    if (ClientServerTestUtil.useLocal()) {
        System.out.println("HTTP Transport Only Exiting");
        return;
    }
    RespectBindingFeature rbf = new RespectBindingFeature(true);
    WebServiceFeature[] wse = new WebServiceFeature[] { rbf };
    Service service = createServiceWithWSDL();
    MemberSubmissionEndpointReference msEPR = createMSEPRStubServiceWithWSDL(service);
    // MemberSubmissionEndpointReference.AttributedQName portTypeName = msEPR.portTypeName;
    // QName portQName = portTypeName.name;
    msEPR.portTypeName.name = null;
    MSEPRString = msEPR.toString();
    Dispatch<Source> dispatch = service.createDispatch(EndpointReference.readFrom(makeStreamSource(MSEPRString)), Source.class, Service.Mode.PAYLOAD, wse);
    Source result = dispatch.invoke(makeStreamSource(MSGSrc));
    JAXBElement<AddNumbersResponse> addNumberResponse = (JAXBElement<AddNumbersResponse>) createJAXBContext().createUnmarshaller().unmarshal(result);
    AddNumbersResponse response = addNumberResponse.getValue();
    assertEquals(response.getReturn(), 2 + 4);
}
Also used : JAXBElement(jakarta.xml.bind.JAXBElement) MemberSubmissionEndpointReference(com.sun.xml.ws.developer.MemberSubmissionEndpointReference) Source(javax.xml.transform.Source)

Aggregations

MemberSubmissionEndpointReference (com.sun.xml.ws.developer.MemberSubmissionEndpointReference)31 W3CEndpointReference (jakarta.xml.ws.wsaddressing.W3CEndpointReference)13 WSEndpointReference (com.sun.xml.ws.api.addressing.WSEndpointReference)8 Element (org.w3c.dom.Element)7 Endpoint (jakarta.xml.ws.Endpoint)6 EndpointReference (jakarta.xml.ws.EndpointReference)6 W3CEndpointReferenceBuilder (jakarta.xml.ws.wsaddressing.W3CEndpointReferenceBuilder)6 URL (java.net.URL)6 ArrayList (java.util.ArrayList)6 DocumentBuilder (javax.xml.parsers.DocumentBuilder)6 DocumentBuilderFactory (javax.xml.parsers.DocumentBuilderFactory)6 Source (javax.xml.transform.Source)6 Document (org.w3c.dom.Document)6 StreamSource (javax.xml.transform.stream.StreamSource)5 JAXBElement (jakarta.xml.bind.JAXBElement)4 HashMap (java.util.HashMap)3 QName (javax.xml.namespace.QName)3 DOMResult (javax.xml.transform.dom.DOMResult)3 MemberSubmissionAddressingFeature (com.sun.xml.ws.developer.MemberSubmissionAddressingFeature)2 JAXBContext (jakarta.xml.bind.JAXBContext)2