Java Code Examples for javax.xml.ws.EndpointReference

The following examples show how to use javax.xml.ws.EndpointReference. These examples are extracted from open source projects. 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 Project: development   Source File: ServiceFactory.java    License: Apache License 2.0 6 votes vote down vote up
private EndpointReference determineEndpointReference(String serviceName)
        throws ParserConfigurationException {
    Document doc = DocumentBuilderFactory.newInstance()
            .newDocumentBuilder().newDocument();
    Element eprNode = doc.createElementNS(
            "http://www.w3.org/2005/08/addressing", "EndpointReference");
    Element addressNode = doc.createElement("Address");
    Element metadataNode = doc.createElement("Metadata");
    String wsdlURL = remoteWSDLUrl.replace("{service}", serviceName);
    addressNode.setTextContent(wsdlURL);
    doc.appendChild(eprNode);
    eprNode.appendChild(addressNode);
    eprNode.appendChild(metadataNode);
    EndpointReference epr = EndpointReference.readFrom(new DOMSource(doc));
    return epr;
}
 
Example 2
/**
 * Gives the EPR based on the clazz. It may need to perform tranformation from
 * W3C EPR to MS EPR or vise-versa.
 */
public static <T extends EndpointReference> T transform(Class<T> clazz, @NotNull EndpointReference epr) {
    assert epr != null;
    if (clazz.isAssignableFrom(W3CEndpointReference.class)) {
        if (epr instanceof W3CEndpointReference) {
            return (T) epr;
        } else if (epr instanceof MemberSubmissionEndpointReference) {
            return (T) toW3CEpr((MemberSubmissionEndpointReference) epr);
        }
    } else if (clazz.isAssignableFrom(MemberSubmissionEndpointReference.class)) {
        if (epr instanceof W3CEndpointReference) {
            return (T) toMSEpr((W3CEndpointReference) epr);
        } else if (epr instanceof MemberSubmissionEndpointReference) {
            return (T) epr;
        }
    }

    //This must be an EPR that we dont know
    throw new WebServiceException("Unknwon EndpointReference: " + epr.getClass());
}
 
Example 3
/**
 * Gives the EPR based on the clazz. It may need to perform tranformation from
 * W3C EPR to MS EPR or vise-versa.
 */
public static <T extends EndpointReference> T transform(Class<T> clazz, @NotNull EndpointReference epr) {
    assert epr != null;
    if (clazz.isAssignableFrom(W3CEndpointReference.class)) {
        if (epr instanceof W3CEndpointReference) {
            return (T) epr;
        } else if (epr instanceof MemberSubmissionEndpointReference) {
            return (T) toW3CEpr((MemberSubmissionEndpointReference) epr);
        }
    } else if (clazz.isAssignableFrom(MemberSubmissionEndpointReference.class)) {
        if (epr instanceof W3CEndpointReference) {
            return (T) toMSEpr((W3CEndpointReference) epr);
        } else if (epr instanceof MemberSubmissionEndpointReference) {
            return (T) epr;
        }
    }

    //This must be an EPR that we dont know
    throw new WebServiceException("Unknwon EndpointReference: " + epr.getClass());
}
 
Example 4
/**
 * Gives the EPR based on the clazz. It may need to perform tranformation from
 * W3C EPR to MS EPR or vise-versa.
 */
public static <T extends EndpointReference> T transform(Class<T> clazz, @NotNull EndpointReference epr) {
    assert epr != null;
    if (clazz.isAssignableFrom(W3CEndpointReference.class)) {
        if (epr instanceof W3CEndpointReference) {
            return (T) epr;
        } else if (epr instanceof MemberSubmissionEndpointReference) {
            return (T) toW3CEpr((MemberSubmissionEndpointReference) epr);
        }
    } else if (clazz.isAssignableFrom(MemberSubmissionEndpointReference.class)) {
        if (epr instanceof W3CEndpointReference) {
            return (T) toMSEpr((W3CEndpointReference) epr);
        } else if (epr instanceof MemberSubmissionEndpointReference) {
            return (T) epr;
        }
    }

    //This must be an EPR that we dont know
    throw new WebServiceException("Unknwon EndpointReference: " + epr.getClass());
}
 
Example 5
/**
 * Gives the EPR based on the clazz. It may need to perform tranformation from
 * W3C EPR to MS EPR or vise-versa.
 */
public static <T extends EndpointReference> T transform(Class<T> clazz, @NotNull EndpointReference epr) {
    assert epr != null;
    if (clazz.isAssignableFrom(W3CEndpointReference.class)) {
        if (epr instanceof W3CEndpointReference) {
            return (T) epr;
        } else if (epr instanceof MemberSubmissionEndpointReference) {
            return (T) toW3CEpr((MemberSubmissionEndpointReference) epr);
        }
    } else if (clazz.isAssignableFrom(MemberSubmissionEndpointReference.class)) {
        if (epr instanceof W3CEndpointReference) {
            return (T) toMSEpr((W3CEndpointReference) epr);
        } else if (epr instanceof MemberSubmissionEndpointReference) {
            return (T) epr;
        }
    }

    //This must be an EPR that we dont know
    throw new WebServiceException("Unknwon EndpointReference: " + epr.getClass());
}
 
Example 6
Source Project: cxf   Source File: EndpointReferenceTest.java    License: Apache License 2.0 6 votes vote down vote up
@Test
public void testServiceGetPortUsingEndpointReference() throws Exception {
    BusFactory.setDefaultBus(getBus());
    GreeterImpl greeter1 = new GreeterImpl();
    try (EndpointImpl endpoint = new EndpointImpl(getBus(), greeter1, (String)null)) {
        endpoint.publish("http://localhost:8080/test");

        javax.xml.ws.Service s = javax.xml.ws.Service
            .create(new QName("http://apache.org/hello_world_soap_http", "SoapPort"));

        InputStream is = getClass().getResourceAsStream("resources/hello_world_soap_http_infoset.xml");
        Document doc = StaxUtils.read(is);
        DOMSource erXML = new DOMSource(doc);
        EndpointReference endpointReference = EndpointReference.readFrom(erXML);

        WebServiceFeature[] wfs = new WebServiceFeature[] {};

        Greeter greeter = s.getPort(endpointReference, Greeter.class, wfs);

        String response = greeter.greetMe("John");

        assertEquals("Hello John", response);
    }
}
 
Example 7
Source Project: hottub   Source File: WSEndpointReference.java    License: GNU General Public License v2.0 5 votes vote down vote up
/**
 * Creates from the spec version of {@link EndpointReference}.
 *
 * <p>
 * This method performs the data conversion, so it's slow.
 * Do not use this method in a performance critical path.
 */
public WSEndpointReference(EndpointReference epr, AddressingVersion version) {
    try {
        MutableXMLStreamBuffer xsb = new MutableXMLStreamBuffer();
        epr.writeTo(new XMLStreamBufferResult(xsb));
        this.infoset = xsb;
        this.version = version;
        this.rootElement = new QName("EndpointReference", version.nsUri);
        parse();
    } catch (XMLStreamException e) {
        throw new WebServiceException(ClientMessages.FAILED_TO_PARSE_EPR(epr),e);
    }
}
 
Example 8
Source Project: cxf   Source File: EndpointReferenceTest.java    License: Apache License 2.0 5 votes vote down vote up
@Test
public void testBindingProviderSOAPBindingStaicService() throws Exception {
    org.apache.hello_world_soap_http.SOAPService s = new org.apache.hello_world_soap_http.SOAPService();

    Greeter greeter = s.getPort(Greeter.class);
    BindingProvider bindingProvider = (BindingProvider)greeter;

    EndpointReference er = bindingProvider.getEndpointReference();
    assertNotNull(er);

    //If the BindingProvider instance has a binding that is either SOAP 1.1/HTTP or SOAP
    //1.2/HTTP, then a W3CEndpointReference MUST be returned.
    assertTrue(er instanceof W3CEndpointReference);
}
 
Example 9
/**
 * Converts from {@link EndpointReference}.
 *
 * This handles null {@link EndpointReference} correctly.
 * Call {@link #WSEndpointReference(EndpointReference)} directly
 * if you know it's not null.
 */
public static @Nullable
WSEndpointReference create(@Nullable EndpointReference epr) {
    if (epr != null) {
        return new WSEndpointReference(epr);
    } else {
        return null;
    }
}
 
Example 10
public <T extends EndpointReference> T getEndpointReference(Class<T> clazz, Element...referenceParameters) {
    Packet packet = getRequestPacket();
    if (packet == null) {
        throw new IllegalStateException("getEndpointReference() can only be called while servicing a request");
    }
    String address = packet.webServiceContextDelegate.getEPRAddress(packet, endpoint);
    String wsdlAddress = null;
    if(endpoint.getServiceDefinition() != null) {
        wsdlAddress = packet.webServiceContextDelegate.getWSDLAddress(packet,endpoint);
    }
    return clazz.cast(endpoint.getEndpointReference(clazz,address,wsdlAddress, referenceParameters));
}
 
Example 11
public <T extends EndpointReference> T getEndpointReference(Class<T> clazz,
        String address, String wsdlAddress, List<Element> metadata,
        List<Element> referenceParameters) {
    QName portType = null;
    if (port != null) {
        portType = port.getBinding().getPortTypeName();
    }

    AddressingVersion av = AddressingVersion.fromSpecClass(clazz);
    return new WSEndpointReference(
            av, address, serviceName, portName, portType, metadata, wsdlAddress, referenceParameters, endpointReferenceExtensions.values(), null).toSpec(clazz);

}
 
Example 12
Source Project: TencentKona-8   Source File: WSEndpointImpl.java    License: GNU General Public License v2.0 5 votes vote down vote up
public <T extends EndpointReference> T getEndpointReference(Class<T> clazz,
        String address, String wsdlAddress, List<Element> metadata,
        List<Element> referenceParameters) {
    QName portType = null;
    if (port != null) {
        portType = port.getBinding().getPortTypeName();
    }

    AddressingVersion av = AddressingVersion.fromSpecClass(clazz);
    return new WSEndpointReference(
            av, address, serviceName, portName, portType, metadata, wsdlAddress, referenceParameters, endpointReferenceExtensions.values(), null).toSpec(clazz);

}
 
Example 13
public <T extends EndpointReference> T getEndpointReference(Class<T> clazz, Element...referenceParameters) {
    Packet packet = getRequestPacket();
    if (packet == null) {
        throw new IllegalStateException("getEndpointReference() can only be called while servicing a request");
    }
    String address = packet.webServiceContextDelegate.getEPRAddress(packet, endpoint);
    String wsdlAddress = null;
    if(endpoint.getServiceDefinition() != null) {
        wsdlAddress = packet.webServiceContextDelegate.getWSDLAddress(packet,endpoint);
    }
    return clazz.cast(endpoint.getEndpointReference(clazz,address,wsdlAddress, referenceParameters));
}
 
Example 14
Source Project: cxf   Source File: EndpointReferenceTest.java    License: Apache License 2.0 5 votes vote down vote up
@Test
public void testProviderReadEndpointReference() throws Exception {
    ProviderImpl provider = new ProviderImpl();

    InputStream is = getClass().getResourceAsStream("resources/hello_world_soap_http_infoset.xml");
    Document doc = StaxUtils.read(is);
    DOMSource erXML = new DOMSource(doc);
    EndpointReference endpointReference = provider.readEndpointReference(erXML);
    assertNotNull(endpointReference);

    assertTrue(endpointReference instanceof W3CEndpointReference);
}
 
Example 15
Source Project: openjdk-jdk9   Source File: ProviderImpl.java    License: GNU General Public License v2.0 5 votes vote down vote up
public EndpointReference readEndpointReference(final Source eprInfoset) {
    try {
        Unmarshaller unmarshaller = eprjc.get().createUnmarshaller();
        return (EndpointReference) unmarshaller.unmarshal(eprInfoset);
    } catch (JAXBException e) {
        throw new WebServiceException("Error creating Marshaller or marshalling.", e);
    }
}
 
Example 16
Source Project: openjdk-8   Source File: WSEndpointImpl.java    License: GNU General Public License v2.0 5 votes vote down vote up
public <T extends EndpointReference> T getEndpointReference(Class<T> clazz, String address, String wsdlAddress, Element... referenceParameters) {
    List<Element> refParams = null;
    if (referenceParameters != null) {
        refParams = Arrays.asList(referenceParameters);
    }
    return getEndpointReference(clazz, address, wsdlAddress, null, refParams);
}
 
Example 17
Source Project: tomee   Source File: JaxWsProviderWrapper.java    License: Apache License 2.0 5 votes vote down vote up
@Override
@SuppressWarnings({"unchecked"})
public <T> T getPort(final EndpointReference endpointReference, final Class<T> serviceEndpointInterface, final WebServiceFeature... features) {
    return (T) invoke21Delegate(serviceDelegate, serviceGetPortByEndpointReference,
        endpointReference,
        serviceEndpointInterface,
        features);
}
 
Example 18
/**
 * Creates from the spec version of {@link EndpointReference}.
 *
 * <p>
 * This method performs the data conversion, so it's slow.
 * Do not use this method in a performance critical path.
 */
public WSEndpointReference(EndpointReference epr, AddressingVersion version) {
    try {
        MutableXMLStreamBuffer xsb = new MutableXMLStreamBuffer();
        epr.writeTo(new XMLStreamBufferResult(xsb));
        this.infoset = xsb;
        this.version = version;
        this.rootElement = new QName("EndpointReference", version.nsUri);
        parse();
    } catch (XMLStreamException e) {
        throw new WebServiceException(ClientMessages.FAILED_TO_PARSE_EPR(epr),e);
    }
}
 
Example 19
public <T extends EndpointReference> T getEndpointReference(Class<T> clazz, Element...referenceParameters) {
    Packet packet = getRequestPacket();
    if (packet == null) {
        throw new IllegalStateException("getEndpointReference() can only be called while servicing a request");
    }
    String address = packet.webServiceContextDelegate.getEPRAddress(packet, endpoint);
    String wsdlAddress = null;
    if(endpoint.getServiceDefinition() != null) {
        wsdlAddress = packet.webServiceContextDelegate.getWSDLAddress(packet,endpoint);
    }
    return clazz.cast(endpoint.getEndpointReference(clazz,address,wsdlAddress, referenceParameters));
}
 
Example 20
Source Project: cxf   Source File: Client.java    License: Apache License 2.0 5 votes vote down vote up
public static void main(String[] args) throws Exception {

        //Use WS-Discovery to find references to services that implement the Greeter portType
        WSDiscoveryClient client = new WSDiscoveryClient();
        List<EndpointReference> references
            = client.probe(new QName("http://cxf.apache.org/hello_world/discovery", "Greeter"));
        client.close();

        GreeterService service = new GreeterService();
        //loop through all of them and have them greet me.
        for (EndpointReference ref : references) {
            Greeter g = service.getPort(ref, Greeter.class);
            System.out.println(g.greetMe("World"));
        }
    }
 
Example 21
public <T extends EndpointReference> T getEndpointReference(Class<T> clazz, Element...referenceParameters) {
    Packet packet = getRequestPacket();
    if (packet == null) {
        throw new IllegalStateException("getEndpointReference() can only be called while servicing a request");
    }
    String address = packet.webServiceContextDelegate.getEPRAddress(packet, endpoint);
    String wsdlAddress = null;
    if(endpoint.getServiceDefinition() != null) {
        wsdlAddress = packet.webServiceContextDelegate.getWSDLAddress(packet,endpoint);
    }
    return clazz.cast(endpoint.getEndpointReference(clazz,address,wsdlAddress, referenceParameters));
}
 
Example 22
/**
 * Creates from the spec version of {@link EndpointReference}.
 *
 * <p>
 * This method performs the data conversion, so it's slow.
 * Do not use this method in a performance critical path.
 */
public WSEndpointReference(EndpointReference epr, AddressingVersion version) {
    try {
        MutableXMLStreamBuffer xsb = new MutableXMLStreamBuffer();
        epr.writeTo(new XMLStreamBufferResult(xsb));
        this.infoset = xsb;
        this.version = version;
        this.rootElement = new QName("EndpointReference", version.nsUri);
        parse();
    } catch (XMLStreamException e) {
        throw new WebServiceException(ClientMessages.FAILED_TO_PARSE_EPR(epr),e);
    }
}
 
Example 23
public EPR(Class<? extends EndpointReference> eprClass, String address, String serviceName, String portName,
            String portTypeName, QName wsdlMetadata,
            String referenceParameters, String referenceProperties) {
    this.eprClass = eprClass;
    this.address = address;
    this.serviceName = serviceName;
    this.portName = portName;
    this.portTypeName = portTypeName;
    this.referenceParameters = referenceParameters;
    this.referenceProperties = referenceProperties;
    this.wsdlMetadata = wsdlMetadata;

}
 
Example 24
Source Project: openjdk-jdk8u   Source File: ProviderImpl.java    License: GNU General Public License v2.0 5 votes vote down vote up
public EndpointReference readEndpointReference(final Source eprInfoset) {
    try {
        Unmarshaller unmarshaller = eprjc.get().createUnmarshaller();
        return (EndpointReference) unmarshaller.unmarshal(eprInfoset);
    } catch (JAXBException e) {
        throw new WebServiceException("Error creating Marshaller or marshalling.", e);
    }
}
 
Example 25
public <T extends EndpointReference> T getEndpointReference(Class<T> clazz, Element...referenceParameters) {
    Packet packet = getRequestPacket();
    if (packet == null) {
        throw new IllegalStateException("getEndpointReference() can only be called while servicing a request");
    }
    String address = packet.webServiceContextDelegate.getEPRAddress(packet, endpoint);
    String wsdlAddress = null;
    if(endpoint.getServiceDefinition() != null) {
        wsdlAddress = packet.webServiceContextDelegate.getWSDLAddress(packet,endpoint);
    }
    return clazz.cast(endpoint.getEndpointReference(clazz,address,wsdlAddress, referenceParameters));
}
 
Example 26
Source Project: openjdk-jdk8u   Source File: WSEndpointImpl.java    License: GNU General Public License v2.0 5 votes vote down vote up
public <T extends EndpointReference> T getEndpointReference(Class<T> clazz, String address, String wsdlAddress, Element... referenceParameters) {
    List<Element> refParams = null;
    if (referenceParameters != null) {
        refParams = Arrays.asList(referenceParameters);
    }
    return getEndpointReference(clazz, address, wsdlAddress, null, refParams);
}
 
Example 27
public <T extends EndpointReference> T getEndpointReference(Class<T> clazz, Element...referenceParameters) {
    Packet packet = getRequestPacket();
    if (packet == null) {
        throw new IllegalStateException("getEndpointReference() can only be called while servicing a request");
    }
    String address = packet.webServiceContextDelegate.getEPRAddress(packet, endpoint);
    String wsdlAddress = null;
    if(endpoint.getServiceDefinition() != null) {
        wsdlAddress = packet.webServiceContextDelegate.getWSDLAddress(packet,endpoint);
    }
    return clazz.cast(endpoint.getEndpointReference(clazz,address,wsdlAddress, referenceParameters));
}
 
Example 28
/**
 * Converts from {@link EndpointReference}.
 *
 * This handles null {@link EndpointReference} correctly.
 * Call {@link #WSEndpointReference(EndpointReference)} directly
 * if you know it's not null.
 */
public static @Nullable
WSEndpointReference create(@Nullable EndpointReference epr) {
    if (epr != null) {
        return new WSEndpointReference(epr);
    } else {
        return null;
    }
}
 
Example 29
Source Project: tomee   Source File: NoAddressingSupport.java    License: Apache License 2.0 4 votes vote down vote up
public <T extends EndpointReference> T getEndpointReference(final Class<T> clazz, final Element... referenceParameters) {
    throw new UnsupportedOperationException("JaxWS 2.1 APIs are not supported.");
}
 
Example 30
Source Project: tomee   Source File: ProviderWrapper.java    License: Apache License 2.0 4 votes vote down vote up
@SuppressWarnings({"unchecked"})
public <T> T getPort(final EndpointReference endpointReference, final Class<T> serviceEndpointInterface, final WebServiceFeature... features) {
    return customizePort((T) invoke21Delegate(serviceDelegate, serviceGetPortByEndpointReference, endpointReference, serviceEndpointInterface, features));
}