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());
}
}
}
}
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());
}
}
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());
}
}
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;
}
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);
}
Aggregations