Search in sources :

Example 1 with EndpointReference

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

the class WSAM_EPRTester method xtestEPR.

public void xtestEPR() throws Exception {
    URL res = getClass().getClassLoader().getResource("epr/mandatory/epr3.xml");
    InputStream is = res.openStream();
    StreamSource s = new StreamSource(is);
    EndpointReference epr = EndpointReference.readFrom(s);
    WSEndpointReference wsepr = new WSEndpointReference(epr);
    WSEndpointReference.Metadata metadata = wsepr.getMetaData();
    System.out.println(metadata.getPortName());
    System.out.println(metadata.getServiceName());
    System.out.println(metadata.getPortTypeName());
}
Also used : FileInputStream(java.io.FileInputStream) InputStream(java.io.InputStream) StreamSource(javax.xml.transform.stream.StreamSource) WSEndpointReference(com.sun.xml.ws.api.addressing.WSEndpointReference) URL(java.net.URL) WSEndpointReference(com.sun.xml.ws.api.addressing.WSEndpointReference) EndpointReference(jakarta.xml.ws.EndpointReference)

Example 2 with EndpointReference

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

the class WSAM_EPRTester method runMandatoryEPRTests.

private void runMandatoryEPRTests() 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(), "mandatory");
    System.out.println("\n\nMandatory 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(e.getMessage());
        // e.printStackTrace();
        }
    }
}
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)

Example 3 with EndpointReference

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

the class EndpointEPRTest method testDefaultEPR.

public void testDefaultEPR() throws Exception {
    int port = PortAllocator.getFreePort();
    String address = "http://localhost:" + port + "/hello";
    Endpoint endpoint = Endpoint.create(new RpcLitEndpoint());
    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) Endpoint(jakarta.xml.ws.Endpoint) W3CEndpointReference(jakarta.xml.ws.wsaddressing.W3CEndpointReference) MemberSubmissionEndpointReference(com.sun.xml.ws.developer.MemberSubmissionEndpointReference) EndpointReference(jakarta.xml.ws.EndpointReference)

Example 4 with EndpointReference

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

the class EndpointEPRTest method testDefaultEPRWithWSDL.

public void testDefaultEPRWithWSDL() throws Exception {
    int port = PortAllocator.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 = { "RpcLitEndpoint.wsdl", "RpcLitAbstract.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 5 with EndpointReference

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

the class ReferenceParametersTest method testReferenceParametersConversion1.

/*
     * Whitebox test for issue564   
     */
/*
    This test has been moved to jaxws-unit test harness so that 2.1.5 tag can be used.
    
    public void testFaultToReferenceParametersJAXBMessage2() throws Exception {
        String requestStr = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>" +
                "<S:Envelope xmlns:S=\"http://www.w3.org/2003/05/soap-envelope\" xmlns:user=\"http://foo.bar\" " +
                "xmlns:wsa=\"http://schemas.xmlsoap.org/ws/2004/08/addressing\">" +
                "<S:Header>" +
                "<wsa:Action>http://example.org/action/echoIn</wsa:Action>" +
                "<wsa:To>http://www.w3.org/2005/08/addressing/anonymous</wsa:To>" +
                "<wsa:MessageID>urn:uuid:1234567890</wsa:MessageID>" +
                "<wsa:ReplyTo>" +
                "<wsa:Address>http://schemas.xmlsoap.org/ws/2004/08/addressing/role/anonymous</wsa:Address>" +
                "<wsa:ReferenceParameters>" +
                "<user:foo>bar</user:foo>" +
                "<user:bar xmlns:user=\"http://foo.bar\">" +
                "<user:foobar>barfoo</user:foobar>" +
                "</user:bar>" +
                "</wsa:ReferenceParameters>" +
                "</wsa:ReplyTo>" +
                "<wsa:FaultTo>" +
                "<wsa:Address>http://schemas.xmlsoap.org/ws/2004/08/addressing/role/anonymous</wsa:Address>" +
                "<wsa:ReferenceParameters>" +
                "<user:foo>bar</user:foo>" +
                "<user:bar xmlns:user=\"http://foo.bar\">" +
                "<user:foobar>barfoo</user:foobar>" +
                "</user:bar>" +
                "</wsa:ReferenceParameters>" +
                "</wsa:FaultTo>" +
                "</S:Header>" +
                "<S:Body>" +
                "<addNumbers xmlns=\"http://example.com/\">" +
                "<number1>10</number1>" +
                "<number2>10</number2>" +
                "</addNumbers>" +
                "</S:Body></S:Envelope>";
        Message message = useStream12Codec(requestStr);
        WSEndpointReference wsepr = message.getHeaders().getFaultTo(AddressingVersion.MEMBER, SOAPVersion.SOAP_12);
        Message m2 = Messages.create("Test Unsupported",AddressingVersion.MEMBER,SOAPVersion.SOAP_12);
        wsepr.addReferenceParameters(m2.getHeaders());
        ByteArrayBuffer baos = new ByteArrayBuffer();
        XMLStreamWriter writer = XMLStreamWriterFactory.create(baos);
        m2.writeTo(writer);
        writer.flush();

        XMLInputFactory readerFactory = XMLInputFactory.newInstance();
        XMLStreamReader reader = readerFactory.createXMLStreamReader(baos.newInputStream());
        Message sm = Messages.create(reader);
        Packet sm_packet = new Packet(sm);
        List<Element> refParams = sm_packet.getReferenceParameters();
        assertEquals("Did n't get expected ReferenceParameters",2,refParams.size());
        for(Element e: refParams) {
            assertEquals("NS Decl did not match", "http://foo.bar", e.getNamespaceURI());
        }
    }
    */
public void testReferenceParametersConversion1() throws Exception {
    DocumentBuilderFactory docFactory = DocumentBuilderFactory.newInstance();
    docFactory.setNamespaceAware(true);
    DocumentBuilder db = docFactory.newDocumentBuilder();
    Document doc = db.newDocument();
    Element el1 = doc.createElementNS("http:foo.bar", "Element1");
    W3CEndpointReferenceBuilder builder = new W3CEndpointReferenceBuilder();
    EndpointReference epr = builder.address("http://foo.bar").referenceParameter(el1).build();
    System.out.println("EPR " + epr);
    WSEndpointReference wsepr = new WSEndpointReference(epr);
    MemberSubmissionEndpointReference translated = wsepr.toSpec(MemberSubmissionEndpointReference.class);
    // System.out.println(translated);
    assert (translated.referenceParameters.elements.size() == 1);
}
Also used : W3CEndpointReferenceBuilder(jakarta.xml.ws.wsaddressing.W3CEndpointReferenceBuilder) DocumentBuilderFactory(javax.xml.parsers.DocumentBuilderFactory) DocumentBuilder(javax.xml.parsers.DocumentBuilder) Element(org.w3c.dom.Element) WSEndpointReference(com.sun.xml.ws.api.addressing.WSEndpointReference) Document(org.w3c.dom.Document) MemberSubmissionEndpointReference(com.sun.xml.ws.developer.MemberSubmissionEndpointReference) WSEndpointReference(com.sun.xml.ws.api.addressing.WSEndpointReference) MemberSubmissionEndpointReference(com.sun.xml.ws.developer.MemberSubmissionEndpointReference) 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