Search in sources :

Example 6 with SOAPAddress

use of javax.wsdl.extensions.soap.SOAPAddress in project cxf by apache.

the class ServiceImpl method initializePorts.

private void initializePorts() {
    try {
        Definition def = bus.getExtension(WSDLManager.class).getDefinition(wsdlURL);
        javax.wsdl.Service serv = def.getService(serviceName);
        if (serv == null) {
            throw new WebServiceException("Could not find service named " + serviceName + " in wsdl " + wsdlURL);
        }
        Map<String, Port> wsdlports = CastUtils.cast(serv.getPorts());
        for (Port port : wsdlports.values()) {
            QName name = new QName(serviceName.getNamespaceURI(), port.getName());
            String address = null;
            String bindingID = null;
            List<? extends ExtensibilityElement> extensions = CastUtils.cast(port.getBinding().getExtensibilityElements());
            if (!extensions.isEmpty()) {
                ExtensibilityElement e = extensions.get(0);
                if (e instanceof SoapBinding) {
                    bindingID = SOAPBinding.SOAP11HTTP_BINDING;
                } else if (e instanceof SOAP12Binding) {
                    bindingID = SOAPBinding.SOAP12HTTP_BINDING;
                } else if (e instanceof javax.wsdl.extensions.soap.SOAPBinding) {
                    bindingID = SOAPBinding.SOAP11HTTP_BINDING;
                }
            }
            extensions = CastUtils.cast(port.getExtensibilityElements());
            if (!extensions.isEmpty()) {
                ExtensibilityElement e = extensions.get(0);
                if (e instanceof SoapAddress) {
                    address = ((SoapAddress) e).getLocationURI();
                } else if (e instanceof AddressType) {
                    address = ((AddressType) e).getLocation();
                } else if (e instanceof SOAP12Address) {
                    address = ((SOAP12Address) e).getLocationURI();
                } else if (e instanceof SOAPAddress) {
                    address = ((SOAPAddress) e).getLocationURI();
                } else if (e instanceof HTTPAddress) {
                    address = ((HTTPAddress) e).getLocationURI();
                }
            }
            addPort(name, bindingID, address);
        }
    } catch (WebServiceException e) {
        throw e;
    } catch (Throwable e) {
        if (e instanceof UncheckedException && LOG.isLoggable(Level.FINE)) {
            LOG.log(Level.FINE, e.getLocalizedMessage(), e);
        }
        WSDLServiceFactory sf = new WSDLServiceFactory(bus, wsdlURL, serviceName);
        Service service = sf.create();
        for (ServiceInfo si : service.getServiceInfos()) {
            for (EndpointInfo ei : si.getEndpoints()) {
                String bindingID = BindingID.getJaxwsBindingID(ei.getTransportId());
                addPort(ei.getName(), bindingID, ei.getAddress());
            }
        }
    }
}
Also used : HTTPAddress(javax.wsdl.extensions.http.HTTPAddress) Port(javax.wsdl.Port) ExtensibilityElement(javax.wsdl.extensions.ExtensibilityElement) ServiceInfo(org.apache.cxf.service.model.ServiceInfo) EndpointInfo(org.apache.cxf.service.model.EndpointInfo) SOAP12Binding(javax.wsdl.extensions.soap12.SOAP12Binding) SOAP12Address(javax.wsdl.extensions.soap12.SOAP12Address) WSDLServiceFactory(org.apache.cxf.wsdl11.WSDLServiceFactory) WebServiceException(javax.xml.ws.WebServiceException) QName(javax.xml.namespace.QName) Definition(javax.wsdl.Definition) SOAPBinding(javax.xml.ws.soap.SOAPBinding) Service(org.apache.cxf.service.Service) WebService(javax.jws.WebService) SoapBinding(org.apache.cxf.binding.soap.wsdl.extensions.SoapBinding) UncheckedException(org.apache.cxf.common.i18n.UncheckedException) SoapAddress(org.apache.cxf.binding.soap.wsdl.extensions.SoapAddress) SOAPAddress(javax.wsdl.extensions.soap.SOAPAddress) WSDLManager(org.apache.cxf.wsdl.WSDLManager) AddressType(org.apache.cxf.wsdl.http.AddressType)

Example 7 with SOAPAddress

use of javax.wsdl.extensions.soap.SOAPAddress in project cxf by apache.

the class WSDLToServiceProcessorTest method testDefaultLocation.

@Test
public void testDefaultLocation() throws Exception {
    String[] args = new String[] { "-transport", "soap", "-e", "serviceins", "-p", "portins", "-n", "Greeter_SOAPBinding", "-d", output.getCanonicalPath(), getLocation("/misctools_wsdl/hello_world.wsdl") };
    WSDLToService.main(args);
    File outputFile = new File(output, "hello_world-service.wsdl");
    assertTrue("New wsdl file is not generated", outputFile.exists());
    WSDLToServiceProcessor processor = new WSDLToServiceProcessor();
    processor.setEnvironment(env);
    try {
        processor.parseWSDL(outputFile.getAbsolutePath());
        Service service = processor.getWSDLDefinition().getService(new QName(processor.getWSDLDefinition().getTargetNamespace(), "serviceins"));
        if (service == null) {
            fail("Element wsdl:service serviceins Missed!");
        }
        Iterator<?> it = service.getPort("portins").getExtensibilityElements().iterator();
        if (it == null || !it.hasNext()) {
            fail("Element wsdl:port portins Missed!");
        }
        boolean found = false;
        while (it.hasNext()) {
            Object obj = it.next();
            if (obj instanceof SOAPAddress) {
                SOAPAddress soapAddress = (SOAPAddress) obj;
                if (soapAddress.getLocationURI() != null && soapAddress.getLocationURI().equals("http://localhost:9000/serviceins/portins")) {
                    found = true;
                    break;
                }
            }
        }
        if (!found) {
            fail("Element soap:address of service port Missed!");
        }
    } catch (ToolException e) {
        fail("Exception Encountered when parsing wsdl, error: " + e.getMessage());
    }
}
Also used : QName(javax.xml.namespace.QName) SOAPAddress(javax.wsdl.extensions.soap.SOAPAddress) WSDLToService(org.apache.cxf.tools.misc.WSDLToService) Service(javax.wsdl.Service) ToolException(org.apache.cxf.tools.common.ToolException) File(java.io.File) Test(org.junit.Test)

Example 8 with SOAPAddress

use of javax.wsdl.extensions.soap.SOAPAddress in project cxf by apache.

the class WSDLToServiceProcessorTest method testNewService.

@Test
public void testNewService() throws Exception {
    String[] args = new String[] { "-transport", "soap", "-e", "serviceins", "-p", "portins", "-n", "Greeter_SOAPBinding", "-a", "http://localhost:9000/newservice/newport", "-d", output.getCanonicalPath(), getLocation("/misctools_wsdl/hello_world.wsdl") };
    WSDLToService.main(args);
    File outputFile = new File(output, "hello_world-service.wsdl");
    assertTrue("New wsdl file is not generated", outputFile.exists());
    WSDLToServiceProcessor processor = new WSDLToServiceProcessor();
    processor.setEnvironment(env);
    try {
        processor.parseWSDL(outputFile.getAbsolutePath());
        Service service = processor.getWSDLDefinition().getService(new QName(processor.getWSDLDefinition().getTargetNamespace(), "serviceins"));
        if (service == null) {
            fail("Element wsdl:service serviceins Missed!");
        }
        Iterator<?> it = service.getPort("portins").getExtensibilityElements().iterator();
        if (it == null || !it.hasNext()) {
            fail("Element wsdl:port portins Missed!");
        }
        boolean found = false;
        while (it.hasNext()) {
            Object obj = it.next();
            if (obj instanceof SOAPAddress) {
                SOAPAddress soapAddress = (SOAPAddress) obj;
                if (soapAddress.getLocationURI() != null && soapAddress.getLocationURI().equals("http://localhost:9000/newservice/newport")) {
                    found = true;
                    break;
                }
            }
        }
        if (!found) {
            fail("Element soap:address of service port Missed!");
        }
    } catch (ToolException e) {
        fail("Exception Encountered when parsing wsdl, error: " + e.getMessage());
    }
}
Also used : QName(javax.xml.namespace.QName) SOAPAddress(javax.wsdl.extensions.soap.SOAPAddress) WSDLToService(org.apache.cxf.tools.misc.WSDLToService) Service(javax.wsdl.Service) ToolException(org.apache.cxf.tools.common.ToolException) File(java.io.File) Test(org.junit.Test)

Example 9 with SOAPAddress

use of javax.wsdl.extensions.soap.SOAPAddress in project carbon-business-process by wso2.

the class BPELProcessProxy method genEPRfromWSDL.

/**
 * Get the EPR of this service from the WSDL.
 *
 * @param wsdlDef     WSDL Definition
 * @param serviceName service name
 * @param portName    port name
 * @return XML representation of the EPR
 */
public static Element genEPRfromWSDL(final Definition wsdlDef, final QName serviceName, final String portName) {
    Service serviceDef = wsdlDef.getService(serviceName);
    if (serviceDef != null) {
        Port portDef = serviceDef.getPort(portName);
        if (portDef != null) {
            Document doc = DOMUtils.newDocument();
            Element service = doc.createElementNS(Namespaces.WSDL_11, "service");
            service.setAttribute("name", serviceDef.getQName().getLocalPart());
            service.setAttribute("targetNamespace", serviceDef.getQName().getNamespaceURI());
            Element port = doc.createElementNS(Namespaces.WSDL_11, "port");
            service.appendChild(port);
            port.setAttribute("name", portDef.getName());
            port.setAttributeNS("http://www.w3.org/2000/xmlns/", "xmlns:bindns", portDef.getBinding().getQName().getNamespaceURI());
            port.setAttribute("bindns:binding", portDef.getName());
            for (Object extElmt : portDef.getExtensibilityElements()) {
                if (extElmt instanceof SOAPAddress) {
                    Element soapAddr = doc.createElementNS(Namespaces.SOAP_NS, "address");
                    port.appendChild(soapAddr);
                    soapAddr.setAttribute("location", ((SOAPAddress) extElmt).getLocationURI());
                } else if (extElmt instanceof HTTPAddress) {
                    Element httpAddr = doc.createElementNS(Namespaces.HTTP_NS, "address");
                    port.appendChild(httpAddr);
                    httpAddr.setAttribute("location", ((HTTPAddress) extElmt).getLocationURI());
                } else if (extElmt instanceof SOAP12Address) {
                    Element soap12Addr = doc.createElementNS(Namespaces.SOAP12_NS, "address");
                    port.appendChild(soap12Addr);
                    soap12Addr.setAttribute("location", ((SOAP12Address) extElmt).getLocationURI());
                } else {
                    port.appendChild(doc.importNode(((UnknownExtensibilityElement) extElmt).getElement(), true));
                }
            }
            return service;
        }
    }
    return null;
}
Also used : HTTPAddress(javax.wsdl.extensions.http.HTTPAddress) Port(javax.wsdl.Port) OMElement(org.apache.axiom.om.OMElement) UnknownExtensibilityElement(javax.wsdl.extensions.UnknownExtensibilityElement) Element(org.w3c.dom.Element) SOAPAddress(javax.wsdl.extensions.soap.SOAPAddress) UnknownExtensibilityElement(javax.wsdl.extensions.UnknownExtensibilityElement) Service(javax.wsdl.Service) AxisService(org.apache.axis2.description.AxisService) Document(org.w3c.dom.Document) SOAP12Address(javax.wsdl.extensions.soap12.SOAP12Address)

Example 10 with SOAPAddress

use of javax.wsdl.extensions.soap.SOAPAddress in project jbossws-cxf by jbossws.

the class JBossWebServicesEarTestCase method testJSEEndpoint.

@Test
@RunAsClient
public void testJSEEndpoint() throws Exception {
    String soapAddress = baseURL + "JSEBean";
    QName serviceName = new QName("http://eardeployment.jaxws/", "EndpointService");
    Service service = Service.create(new URL(soapAddress + "?wsdl"), serviceName);
    Endpoint port = service.getPort(Endpoint.class);
    // check soap address rewrite to verify jboss-webservices.xml override
    Definition wsdl = getWSDLDefinition(soapAddress + "?wsdl");
    SOAPAddress sa = (SOAPAddress) wsdl.getService(serviceName).getPort("EndpointPort").getExtensibilityElements().iterator().next();
    assertEquals("https://foo-test:" + JBossWSTestHelper.getSecureServerPort(null, null) + "/earjse2/JSEBean", sa.getLocationURI());
    BindingProvider bp = (BindingProvider) port;
    bp.getRequestContext().put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY, soapAddress);
    String helloWorld = "Hello world!";
    String retObj = port.echo(helloWorld);
    assertEquals(helloWorld, retObj);
}
Also used : QName(javax.xml.namespace.QName) SOAPAddress(javax.wsdl.extensions.soap.SOAPAddress) Definition(javax.wsdl.Definition) Service(javax.xml.ws.Service) BindingProvider(javax.xml.ws.BindingProvider) URL(java.net.URL) RunAsClient(org.jboss.arquillian.container.test.api.RunAsClient) Test(org.junit.Test) JBossWSTest(org.jboss.wsf.test.JBossWSTest)

Aggregations

SOAPAddress (javax.wsdl.extensions.soap.SOAPAddress)22 Port (javax.wsdl.Port)12 QName (javax.xml.namespace.QName)9 Service (javax.wsdl.Service)7 SOAP12Address (javax.wsdl.extensions.soap12.SOAP12Address)7 Definition (javax.wsdl.Definition)5 Test (org.junit.Test)5 List (java.util.List)4 ExtensibilityElement (javax.wsdl.extensions.ExtensibilityElement)4 HTTPAddress (javax.wsdl.extensions.http.HTTPAddress)4 URL (java.net.URL)3 Iterator (java.util.Iterator)3 Binding (javax.wsdl.Binding)3 File (java.io.File)2 Map (java.util.Map)2 BindingOperation (javax.wsdl.BindingOperation)2 UnknownExtensibilityElement (javax.wsdl.extensions.UnknownExtensibilityElement)2 SOAPBinding (javax.wsdl.extensions.soap.SOAPBinding)2 SOAPOperation (javax.wsdl.extensions.soap.SOAPOperation)2 ToolException (org.apache.cxf.tools.common.ToolException)2