Search in sources :

Example 11 with EndpointReference

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

the class EndpointEPRTester method testDefaultEPRWithWSDL.

public void testDefaultEPRWithWSDL() 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);
    EndpointReference epr = endpoint.getEndpointReference();
    endpoint.stop();
    EprUtil.validateEPR(epr, address, null, /*serviceName*/
    null, /*portName*/
    null, /* portTypeName */
    Boolean.FALSE);
    printEPR(epr);
}
Also used : Endpoint(jakarta.xml.ws.Endpoint) StreamSource(javax.xml.transform.stream.StreamSource) ArrayList(java.util.ArrayList) Endpoint(jakarta.xml.ws.Endpoint) StreamSource(javax.xml.transform.stream.StreamSource) Source(javax.xml.transform.Source) URL(java.net.URL) W3CEndpointReference(jakarta.xml.ws.wsaddressing.W3CEndpointReference) MemberSubmissionEndpointReference(com.sun.xml.ws.developer.MemberSubmissionEndpointReference) EndpointReference(jakarta.xml.ws.EndpointReference)

Example 12 with EndpointReference

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

the class EPRWriteNReadTest method verifyEPR.

private static void verifyEPR(WSEndpointReference wsepr) throws Exception {
    ByteArrayBuffer bytebuffer = new ByteArrayBuffer();
    XMLStreamWriter w = XMLOutputFactory.newInstance().createXMLStreamWriter(bytebuffer);
    System.out.println("----------------------------------------------------------------------");
    w.writeStartDocument();
    wsepr.writeTo("EndpointReference", w);
    w.writeEndDocument();
    System.out.println(bytebuffer.toString());
    // verify the validity of infoset by reading it as EPR back again
    EndpointReference epr = W3CEndpointReference.readFrom(new StreamSource(bytebuffer.newInputStream()));
    // Verify it good old way
    XMLStreamReader xsr = XMLInputFactory.newInstance().createXMLStreamReader(new StreamSource(bytebuffer.newInputStream()));
    QName q = new QName("http://schemas.xmlsoap.org/ws/2006/02/addressingidentity", "Identity");
    while (xsr.hasNext()) {
        xsr.next();
        if (xsr.getEventType() == XMLStreamConstants.START_ELEMENT && xsr.getLocalName().equals("Identity")) {
            assertEquals(q.getNamespaceURI(), xsr.getNamespaceURI());
        }
    }
}
Also used : QName(javax.xml.namespace.QName) StreamSource(javax.xml.transform.stream.StreamSource) ByteArrayBuffer(com.sun.xml.ws.util.ByteArrayBuffer) W3CEndpointReference(jakarta.xml.ws.wsaddressing.W3CEndpointReference) WSEndpointReference(com.sun.xml.ws.api.addressing.WSEndpointReference) EndpointReference(jakarta.xml.ws.EndpointReference)

Example 13 with EndpointReference

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

the class TubelineAssemblerFactoryImplTest method getClientContext.

private ClientTubeAssemblerContext getClientContext(final BindingID bindingId, final Container container) {
    final WSBinding binding = bindingId.createBinding();
    final EndpointAddress address = new EndpointAddress(ADDRESS_URL);
    final WSDLPort port = null;
    final QName serviceName = new QName(NAMESPACE, "Service1Service");
    WSService service = WSService.create(serviceName);
    final QName portName = new QName(NAMESPACE, "Service1Port");
    // Corresponds to Service.addPort(portName, bindingId, address)
    service.addPort(portName, bindingId.toString(), ADDRESS_URL.toString());
    final WSPortInfo portInfo = ((WSServiceDelegate) service).safeGetPort(portName);
    WSBindingProvider wsbp = new WSBindingProvider() {

        public void setOutboundHeaders(List<Header> headers) {
            throw new UnsupportedOperationException("Not supported yet.");
        }

        public void setOutboundHeaders(Header... headers) {
            throw new UnsupportedOperationException("Not supported yet.");
        }

        public void setOutboundHeaders(Object... headers) {
            throw new UnsupportedOperationException("Not supported yet.");
        }

        public List<Header> getInboundHeaders() {
            throw new UnsupportedOperationException("Not supported yet.");
        }

        public void setAddress(String address) {
            throw new UnsupportedOperationException("Not supported yet.");
        }

        public WSEndpointReference getWSEndpointReference() {
            throw new UnsupportedOperationException("Not supported yet.");
        }

        public WSPortInfo getPortInfo() {
            return portInfo;
        }

        public Map<String, Object> getRequestContext() {
            throw new UnsupportedOperationException("Not supported yet.");
        }

        public Map<String, Object> getResponseContext() {
            throw new UnsupportedOperationException("Not supported yet.");
        }

        public Binding getBinding() {
            return binding;
        }

        public EndpointReference getEndpointReference() {
            throw new UnsupportedOperationException("Not supported yet.");
        }

        public <T extends EndpointReference> T getEndpointReference(Class<T> clazz) {
            throw new UnsupportedOperationException("Not supported yet.");
        }

        public void close() throws IOException {
            throw new UnsupportedOperationException("Not supported yet.");
        }

        public ManagedObjectManager getManagedObjectManager() {
            return null;
        }

        public Set<Component> getComponents() {
            throw new UnsupportedOperationException("Not supported yet.");
        }

        public <S> S getSPI(Class<S> type) {
            throw new UnsupportedOperationException("Not supported yet.");
        }
    };
    final ClientTubeAssemblerContext context = new ClientTubeAssemblerContext(address, port, wsbp, binding, container, ((BindingImpl) binding).createCodec(), null, null);
    return context;
}
Also used : WSBinding(com.sun.xml.ws.api.WSBinding) QName(javax.xml.namespace.QName) WSService(com.sun.xml.ws.api.WSService) WSPortInfo(com.sun.xml.ws.api.client.WSPortInfo) WSDLPort(com.sun.xml.ws.api.model.wsdl.WSDLPort) WSEndpointReference(com.sun.xml.ws.api.addressing.WSEndpointReference) EndpointReference(jakarta.xml.ws.EndpointReference) Header(com.sun.xml.ws.api.message.Header) WSServiceDelegate(com.sun.xml.ws.client.WSServiceDelegate) WSBindingProvider(com.sun.xml.ws.developer.WSBindingProvider) List(java.util.List) Component(com.sun.xml.ws.api.Component) ClientTubeAssemblerContext(com.sun.xml.ws.api.pipe.ClientTubeAssemblerContext) EndpointAddress(com.sun.xml.ws.api.EndpointAddress)

Example 14 with EndpointReference

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

the class TubelineAssemblerFactoryImplTest method testDispatch.

/**
 * Execute a sequence that corresponds to:
 * <pre>
 *   Service.createService(null, serviceName);
 *   Service.addPort(portName, bindingId, address);
 * </pre>
 */
private Tube testDispatch(String configFileName) throws PolicyException {
    final URL wsdlLocation = null;
    final QName serviceName = new QName(NAMESPACE, "Service1Service");
    // Corresponds to Service.createService(wsdlLocation, serviceName)
    final WSServiceDelegate serviceDelegate = new WSServiceDelegate(wsdlLocation, serviceName, Service.class);
    final QName portName = new QName(NAMESPACE, "Service1Port");
    final BindingID bindingId = BindingID.SOAP11_HTTP;
    // Corresponds to Service.addPort(portName, bindingId, address)
    serviceDelegate.addPort(portName, bindingId.toString(), ADDRESS_URL.toString());
    final EndpointAddress address = new EndpointAddress(ADDRESS_URL);
    final WSDLPort port = null;
    final WSPortInfo portInfo = serviceDelegate.safeGetPort(portName);
    final WSBinding binding = bindingId.createBinding(new AddressingFeature(true));
    final Container container = MockupMetroConfigLoader.createMockupContainer("tubes-config/" + configFileName);
    WSBindingProvider wsbp = new WSBindingProvider() {

        public void setOutboundHeaders(List<Header> headers) {
            throw new UnsupportedOperationException("Not supported yet.");
        }

        public void setOutboundHeaders(Header... headers) {
            throw new UnsupportedOperationException("Not supported yet.");
        }

        public void setOutboundHeaders(Object... headers) {
            throw new UnsupportedOperationException("Not supported yet.");
        }

        public List<Header> getInboundHeaders() {
            throw new UnsupportedOperationException("Not supported yet.");
        }

        public void setAddress(String address) {
            throw new UnsupportedOperationException("Not supported yet.");
        }

        public WSEndpointReference getWSEndpointReference() {
            throw new UnsupportedOperationException("Not supported yet.");
        }

        public WSPortInfo getPortInfo() {
            return portInfo;
        }

        public Map<String, Object> getRequestContext() {
            throw new UnsupportedOperationException("Not supported yet.");
        }

        public Map<String, Object> getResponseContext() {
            throw new UnsupportedOperationException("Not supported yet.");
        }

        public Binding getBinding() {
            return binding;
        }

        public EndpointReference getEndpointReference() {
            throw new UnsupportedOperationException("Not supported yet.");
        }

        public <T extends EndpointReference> T getEndpointReference(Class<T> clazz) {
            throw new UnsupportedOperationException("Not supported yet.");
        }

        public void close() throws IOException {
            throw new UnsupportedOperationException("Not supported yet.");
        }

        public ManagedObjectManager getManagedObjectManager() {
            return null;
        }

        public Set<Component> getComponents() {
            throw new UnsupportedOperationException("Not supported yet.");
        }

        public <S> S getSPI(Class<S> type) {
            throw new UnsupportedOperationException("Not supported yet.");
        }
    };
    final ClientTubeAssemblerContext context = new ClientTubeAssemblerContext(address, port, wsbp, binding, container, ((BindingImpl) binding).createCodec(), null, null);
    return getAssembler(bindingId).createClient(context);
}
Also used : WSBinding(com.sun.xml.ws.api.WSBinding) AddressingFeature(jakarta.xml.ws.soap.AddressingFeature) QName(javax.xml.namespace.QName) BindingID(com.sun.xml.ws.api.BindingID) URL(java.net.URL) WSPortInfo(com.sun.xml.ws.api.client.WSPortInfo) WSDLPort(com.sun.xml.ws.api.model.wsdl.WSDLPort) WSEndpointReference(com.sun.xml.ws.api.addressing.WSEndpointReference) EndpointReference(jakarta.xml.ws.EndpointReference) Container(com.sun.xml.ws.api.server.Container) Header(com.sun.xml.ws.api.message.Header) WSServiceDelegate(com.sun.xml.ws.client.WSServiceDelegate) WSBindingProvider(com.sun.xml.ws.developer.WSBindingProvider) List(java.util.List) Component(com.sun.xml.ws.api.Component) ClientTubeAssemblerContext(com.sun.xml.ws.api.pipe.ClientTubeAssemblerContext) EndpointAddress(com.sun.xml.ws.api.EndpointAddress)

Example 15 with EndpointReference

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

the class WSAM_EPRTester method runOptionalEPRTests.

private void runOptionalEPRTests() throws Exception {
    URL res = getClass().getClassLoader().getResource("epr/wsamTest.wsdl");
    // assuming that this is a file:// URL.
    File folder = new File(new File(res.getFile()).getParentFile(), "optional");
    System.out.println("\n\nOptional Tests:\n");
    for (File f : folder.listFiles()) {
        if (!f.getName().endsWith(".xml"))
            continue;
        System.out.println("***************************");
        System.out.println("TestFile: " + f.getParentFile().getName() + "/" + f.getName());
        try {
            InputStream is = new FileInputStream(f);
            StreamSource s = new StreamSource(is);
            EndpointReference epr = EndpointReference.readFrom(s);
            WSEndpointReference wsepr = new WSEndpointReference(epr);
            System.out.println("Address: " + wsepr.getAddress());
            WSEndpointReference.Metadata metadata = wsepr.getMetaData();
            System.out.println("Metadata Valid?: true");
            if (metadata.getPortTypeName() != null)
                System.out.println("InterfaceName: " + metadata.getPortTypeName());
            if (metadata.getServiceName() != null)
                System.out.println("ServiceName: " + metadata.getServiceName());
            if (metadata.getPortName() != null)
                System.out.println("Endpoint: " + metadata.getPortName().getLocalPart());
            String wsdliLocation = metadata.getWsdliLocation();
            if (metadata.getWsdliLocation() != null) {
                System.out.println("wsdli:wsdlLocation: " + wsdliLocation);
                String wsdlLocation = wsdliLocation.substring(wsdliLocation.lastIndexOf(" "));
                WSDLModel wsdlModel = RuntimeWSDLParser.parse(new URL(wsdlLocation), new StreamSource(wsdlLocation), XmlUtil.createDefaultCatalogResolver(), false, Container.NONE, ServiceFinder.find(WSDLParserExtension.class).toArray());
                QName binding = wsdlModel.getBinding(metadata.getServiceName(), metadata.getPortName()).getName();
                System.out.println("Binding from WSDL: " + binding);
            }
            System.out.println("");
        } catch (Exception e) {
            System.out.println("Metadata Valid?: false");
            System.out.println("Reason: " + e.getMessage());
            // e.printStackTrace();
            System.out.println("");
        }
    }
}
Also used : FileInputStream(java.io.FileInputStream) InputStream(java.io.InputStream) QName(javax.xml.namespace.QName) StreamSource(javax.xml.transform.stream.StreamSource) WSEndpointReference(com.sun.xml.ws.api.addressing.WSEndpointReference) WSDLModel(com.sun.xml.ws.api.model.wsdl.WSDLModel) File(java.io.File) URL(java.net.URL) FileInputStream(java.io.FileInputStream) WSEndpointReference(com.sun.xml.ws.api.addressing.WSEndpointReference) EndpointReference(jakarta.xml.ws.EndpointReference)

Aggregations

EndpointReference (jakarta.xml.ws.EndpointReference)17 WSEndpointReference (com.sun.xml.ws.api.addressing.WSEndpointReference)13 MemberSubmissionEndpointReference (com.sun.xml.ws.developer.MemberSubmissionEndpointReference)10 URL (java.net.URL)7 StreamSource (javax.xml.transform.stream.StreamSource)7 W3CEndpointReferenceBuilder (jakarta.xml.ws.wsaddressing.W3CEndpointReferenceBuilder)6 QName (javax.xml.namespace.QName)6 DocumentBuilder (javax.xml.parsers.DocumentBuilder)6 DocumentBuilderFactory (javax.xml.parsers.DocumentBuilderFactory)6 Document (org.w3c.dom.Document)6 Element (org.w3c.dom.Element)6 W3CEndpointReference (jakarta.xml.ws.wsaddressing.W3CEndpointReference)5 Endpoint (jakarta.xml.ws.Endpoint)4 FileInputStream (java.io.FileInputStream)4 InputStream (java.io.InputStream)4 File (java.io.File)3 Component (com.sun.xml.ws.api.Component)2 EndpointAddress (com.sun.xml.ws.api.EndpointAddress)2 WSBinding (com.sun.xml.ws.api.WSBinding)2 WSPortInfo (com.sun.xml.ws.api.client.WSPortInfo)2