use of javax.wsdl.Service 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.Service in project cxf by apache.
the class WSDLToXMLProcessorTest method testAllDefault.
@Test
public void testAllDefault() throws Exception {
String[] args = new String[] { "-i", "Greeter", "-d", output.getCanonicalPath(), getLocation("/misctools_wsdl/hello_world.wsdl") };
WSDLToXML.main(args);
File outputFile = new File(output, "hello_world-xmlbinding.wsdl");
assertTrue("New wsdl file is not generated", outputFile.exists());
WSDLToXMLProcessor processor = new WSDLToXMLProcessor();
processor.setEnvironment(env);
processor.parseWSDL(outputFile.getAbsolutePath());
Binding binding = processor.getWSDLDefinition().getBinding(new QName(processor.getWSDLDefinition().getTargetNamespace(), "Greeter_XMLBinding"));
if (binding == null) {
fail("Element wsdl:binding Greeter_XMLBinding Missed!");
}
boolean found = false;
for (Object obj : binding.getExtensibilityElements()) {
if (obj instanceof XMLFormatBinding) {
found = true;
break;
}
}
if (!found) {
fail("Element <xformat:binding/> Missed!");
}
BindingOperation bo = binding.getBindingOperation("sayHi", null, null);
if (bo == null) {
fail("Element <wsdl:operation name=\"sayHi\"> Missed!");
}
found = false;
for (Object obj : bo.getBindingInput().getExtensibilityElements()) {
if (obj instanceof XMLBindingMessageFormat && ((XMLBindingMessageFormat) obj).getRootNode().getLocalPart().equals("sayHi")) {
found = true;
break;
}
}
if (!found) {
fail("Element <xformat:body rootNode=\"tns:sayHi\" /> Missed!");
}
Service service = processor.getWSDLDefinition().getService(new QName(processor.getWSDLDefinition().getTargetNamespace(), "Greeter_XMLService"));
if (service == null) {
fail("Element wsdl:service Greeter_XMLService Missed!");
}
found = false;
for (Object obj : service.getPort("Greeter_XMLPort").getExtensibilityElements()) {
if (obj instanceof HTTPAddress) {
HTTPAddress xmlHttpAddress = (HTTPAddress) obj;
if (xmlHttpAddress.getLocationURI() != null) {
found = true;
break;
}
}
}
if (!found) {
fail("Element http:address of service port Missed!");
}
}
use of javax.wsdl.Service in project cxf by apache.
the class WSDLDefinitionBuilderTest method testBuildSimpleWSDL.
@Test
public void testBuildSimpleWSDL() throws Exception {
String qname = "http://apache.org/hello_world_soap_http";
String wsdlUrl = getClass().getResource("hello_world.wsdl").toString();
WSDLDefinitionBuilder builder = new WSDLDefinitionBuilder(BusFactory.getDefaultBus());
Definition def = builder.build(wsdlUrl);
assertNotNull(def);
Map<?, ?> services = def.getServices();
assertNotNull(services);
assertEquals(1, services.size());
Service service = (Service) services.get(new QName(qname, "SOAPService"));
assertNotNull(service);
Map<?, ?> ports = service.getPorts();
assertNotNull(ports);
assertEquals(1, ports.size());
Port port = service.getPort("SoapPort");
assertNotNull(port);
}
use of javax.wsdl.Service 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.Service in project carbon-business-process by wso2.
the class HTTPBindingHandler method inferBinding.
private void inferBinding() {
Service serviceDef = wsdl.getService(serviceName);
if (serviceDef == null) {
throw new NullPointerException(Messages.msgServiceDefinitionNotFound(serviceName.getLocalPart()));
}
Port port = serviceDef.getPort(portName);
if (port == null) {
throw new NullPointerException(Messages.msgServicePortNotFound(serviceName.getLocalPart(), portName));
}
httpBinding = port.getBinding();
if (httpBinding == null) {
throw new NullPointerException(Messages.msgBindingNotFound(serviceName.getLocalPart(), portName));
}
}
Aggregations