Java Code Examples for javax.xml.ws.wsaddressing.W3CEndpointReferenceBuilder#endpointName()

The following examples show how to use javax.xml.ws.wsaddressing.W3CEndpointReferenceBuilder#endpointName() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: DispatchClientServerTest.java    From cxf with Apache License 2.0 6 votes vote down vote up
@Test
public void testJAXBObjectPAYLOADFromEPR() throws Exception {
    URL wsdl = getClass().getResource("/wsdl/hello_world.wsdl");
    assertNotNull(wsdl);

    SOAPService service = new SOAPService(wsdl, SERVICE_NAME);
    assertNotNull(service);

    W3CEndpointReferenceBuilder builder = new  W3CEndpointReferenceBuilder();
    builder.address("http://localhost:"
                    + greeterPort
                    + "/SOAPDispatchService/SoapDispatchPort");
    builder.serviceName(SERVICE_NAME);
    builder.endpointName(PORT_NAME);
    W3CEndpointReference w3cEpr = builder.build();
    JAXBContext jc = JAXBContext.newInstance("org.apache.hello_world_soap_http.types");
    Dispatch<Object> disp = service.createDispatch(w3cEpr, jc, Service.Mode.PAYLOAD, new AddressingFeature());
    doJAXBPayload(disp);
}
 
Example 2
Source File: EjbMessageContext.java    From tomee with Apache License 2.0 6 votes vote down vote up
public EndpointReference getEndpointReference(Element... referenceParameters) {
    org.apache.cxf.message.Message msg = getWrappedMessage();
    Endpoint ep = msg.getExchange().get(Endpoint.class);

    W3CEndpointReferenceBuilder builder = new W3CEndpointReferenceBuilder();
    builder.address(ep.getEndpointInfo().getAddress());
    builder.serviceName(ep.getService().getName());
    builder.endpointName(ep.getEndpointInfo().getName());

    if (referenceParameters != null) {
        for (Element referenceParameter : referenceParameters) {
            builder.referenceParameter(referenceParameter);
        }
    }

    return builder.build();
}
 
Example 3
Source File: DispatchClientServerTest.java    From cxf with Apache License 2.0 5 votes vote down vote up
@Test
public void testCreateDispatchWithEPR() throws Exception {

    URL wsdl = getClass().getResource("/wsdl/hello_world.wsdl");
    assertNotNull(wsdl);

    SOAPService service = new SOAPService(wsdl, SERVICE_NAME);
    assertNotNull(service);

    W3CEndpointReferenceBuilder builder = new  W3CEndpointReferenceBuilder();
    builder.address("http://localhost:"
                    + greeterPort
                    + "/SOAPDispatchService/SoapDispatchPort");
    builder.serviceName(SERVICE_NAME);
    builder.endpointName(PORT_NAME);
    W3CEndpointReference w3cEpr = builder.build();
    Dispatch<SOAPMessage> disp = service
        .createDispatch(w3cEpr, SOAPMessage.class, Service.Mode.MESSAGE);
    InputStream is = getClass().getResourceAsStream("resources/GreetMeDocLiteralReq.xml");
    SOAPMessage soapReqMsg = MessageFactory.newInstance().createMessage(null, is);
    assertNotNull(soapReqMsg);
    SOAPMessage soapResMsg = disp.invoke(soapReqMsg);

    assertNotNull(soapResMsg);
    String expected = "Hello TestSOAPInputMessage";
    assertEquals("Response should be : Hello TestSOAPInputMessage", expected,
                 DOMUtils.getAllContent(SAAJUtils.getBody(soapResMsg)).trim());
}
 
Example 4
Source File: EndpointImpl.java    From cxf with Apache License 2.0 5 votes vote down vote up
public EndpointReference getEndpointReference(Element... referenceParameters) {
    if (!isPublished()) {
        throw new WebServiceException(new org.apache.cxf.common.i18n.Message("ENDPOINT_NOT_PUBLISHED",
                                                                             LOG).toString());
    }

    if (getBinding() instanceof HTTPBinding) {
        throw new UnsupportedOperationException(new org.apache.cxf.common.i18n.Message(
                                                    "GET_ENDPOINTREFERENCE_UNSUPPORTED_BINDING",
                                                    LOG).toString());
    }

    W3CEndpointReferenceBuilder builder = new W3CEndpointReferenceBuilder();
    builder.address(address);
    builder.serviceName(serviceName);
    builder.endpointName(endpointName);
    if (referenceParameters != null) {
        for (Element referenceParameter : referenceParameters) {
            builder.referenceParameter(referenceParameter);
        }
    }
    builder.wsdlDocumentLocation(wsdlLocation);

    ClassLoader cl = Thread.currentThread().getContextClassLoader();
    try {
        Thread.currentThread().setContextClassLoader(EndpointReferenceBuilder.class.getClassLoader());
        return builder.build();
    } finally {
        Thread.currentThread().setContextClassLoader(cl);
    }
}
 
Example 5
Source File: EndpointReferenceBuilder.java    From cxf with Apache License 2.0 4 votes vote down vote up
public EndpointReference getEndpointReference() {

        //if there is epr in wsdl, direct return this EPR
        List<ExtensibilityElement> portExtensors = endpoint.getEndpointInfo()
            .getExtensors(ExtensibilityElement.class);
        if (portExtensors != null) {
            Iterator<ExtensibilityElement> extensionElements = portExtensors.iterator();
            QName wsaEpr = new QName(Names.WSA_NAMESPACE_NAME, "EndpointReference");
            while (extensionElements.hasNext()) {
                ExtensibilityElement ext = extensionElements.next();
                if (ext instanceof UnknownExtensibilityElement && wsaEpr.equals(ext.getElementType())) {
                    Element eprEle = ((UnknownExtensibilityElement)ext).getElement();
                    List<Element> addressElements = DOMUtils.getChildrenWithName(eprEle,
                                                                                 Names.WSA_NAMESPACE_NAME,
                                                                                 Names.WSA_ADDRESS_NAME);
                    if (!addressElements.isEmpty()) {
                        /*
                         * [WSA-WSDL Binding] : in a SOAP 1.1 port described using WSDL 1.1, the location
                         * attribute of a soap11:address element (if present) would have the same value as the
                         * wsa:Address child element of the wsa:EndpointReference element.
                         */
                        addressElements.get(0).setTextContent(this.endpoint.getEndpointInfo().getAddress());
                    }
                    return EndpointReference.readFrom(new DOMSource(eprEle));
                }

            }
        }


        String bindingId = endpoint.getJaxwsBinding().getBindingID();

        if (!SOAPBindingImpl.isSoapBinding(bindingId)) {
            throw new UnsupportedOperationException(new Message("GET_ENDPOINTREFERENCE_UNSUPPORTED_BINDING",
                                                                LOG, bindingId).toString());
        }

        W3CEndpointReferenceBuilder builder = new W3CEndpointReferenceBuilder();
        builder.address(this.endpoint.getEndpointInfo().getAddress());

        builder.serviceName(this.endpoint.getService().getName());
        builder.endpointName(this.endpoint.getEndpointInfo().getName());

        if (this.endpoint.getEndpointInfo().getService().getDescription() != null) {
            builder.wsdlDocumentLocation(this.endpoint.getEndpointInfo().getService().getDescription()
                .getBaseURI());
        }
        ClassLoader cl = Thread.currentThread().getContextClassLoader();
        try {
            Thread.currentThread().setContextClassLoader(EndpointReferenceBuilder.class.getClassLoader());

            return builder.build();
        } finally {
            Thread.currentThread().setContextClassLoader(cl);
        }
    }