use of javax.wsdl.extensions.soap.SOAPOperation in project ofbiz-framework by apache.
the class ModelService method getWSDL.
public void getWSDL(Definition def, String locationURI) throws WSDLException {
DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
DocumentBuilder builder = null;
Document document = null;
try {
builder = factory.newDocumentBuilder();
document = builder.newDocument();
} catch (Exception e) {
throw new WSDLException("can not create WSDL", module);
}
def.setTypes(this.getTypes(document, def));
// set the IN parameters
Input input = def.createInput();
Set<String> inParam = this.getInParamNames();
Message inMessage = def.createMessage();
inMessage.setQName(new QName(TNS, this.name + "Request"));
inMessage.setUndefined(false);
Part parametersPart = def.createPart();
parametersPart.setName("map-Map");
parametersPart.setTypeName(new QName(TNS, "map-Map"));
inMessage.addPart(parametersPart);
Element documentation = document.createElement("wsdl:documentation");
for (String paramName : inParam) {
ModelParam param = this.getParam(paramName);
if (!param.internal) {
Part part = param.getWSDLPart(def);
Element attribute = document.createElement("attribute");
attribute.setAttribute("name", paramName);
attribute.setAttribute("type", part.getTypeName().getLocalPart());
attribute.setAttribute("namespace", part.getTypeName().getNamespaceURI());
attribute.setAttribute("java-class", param.type);
attribute.setAttribute("optional", Boolean.toString(param.optional));
documentation.appendChild(attribute);
}
}
Element usernameAttr = document.createElement("attribute");
usernameAttr.setAttribute("name", "login.username");
usernameAttr.setAttribute("type", "std-String");
usernameAttr.setAttribute("namespace", TNS);
usernameAttr.setAttribute("java-class", String.class.getName());
usernameAttr.setAttribute("optional", Boolean.toString(!this.auth));
documentation.appendChild(usernameAttr);
Element passwordAttr = document.createElement("attribute");
passwordAttr.setAttribute("name", "login.password");
passwordAttr.setAttribute("type", "std-String");
passwordAttr.setAttribute("namespace", TNS);
passwordAttr.setAttribute("java-class", String.class.getName());
passwordAttr.setAttribute("optional", Boolean.toString(!this.auth));
documentation.appendChild(passwordAttr);
parametersPart.setDocumentationElement(documentation);
def.addMessage(inMessage);
input.setMessage(inMessage);
// set the OUT parameters
Output output = def.createOutput();
Set<String> outParam = this.getOutParamNames();
Message outMessage = def.createMessage();
outMessage.setQName(new QName(TNS, this.name + "Response"));
outMessage.setUndefined(false);
Part resultsPart = def.createPart();
resultsPart.setName("map-Map");
resultsPart.setTypeName(new QName(TNS, "map-Map"));
outMessage.addPart(resultsPart);
documentation = document.createElement("wsdl:documentation");
for (String paramName : outParam) {
ModelParam param = this.getParam(paramName);
if (!param.internal) {
Part part = param.getWSDLPart(def);
Element attribute = document.createElement("attribute");
attribute.setAttribute("name", paramName);
attribute.setAttribute("type", part.getTypeName().getLocalPart());
attribute.setAttribute("namespace", part.getTypeName().getNamespaceURI());
attribute.setAttribute("java-class", param.type);
attribute.setAttribute("optional", Boolean.toString(param.optional));
documentation.appendChild(attribute);
}
}
resultsPart.setDocumentationElement(documentation);
def.addMessage(outMessage);
output.setMessage(outMessage);
// set port type
Operation operation = def.createOperation();
operation.setName(this.name);
operation.setUndefined(false);
operation.setOutput(output);
operation.setInput(input);
PortType portType = def.createPortType();
portType.setQName(new QName(TNS, this.name + "PortType"));
portType.addOperation(operation);
portType.setUndefined(false);
def.addPortType(portType);
// SOAP binding
SOAPBinding soapBinding = new SOAPBindingImpl();
soapBinding.setStyle("rpc");
soapBinding.setTransportURI("http://schemas.xmlsoap.org/soap/http");
Binding binding = def.createBinding();
binding.setQName(new QName(TNS, this.name + "SoapBinding"));
binding.setPortType(portType);
binding.setUndefined(false);
binding.addExtensibilityElement(soapBinding);
BindingOperation bindingOperation = def.createBindingOperation();
bindingOperation.setName(operation.getName());
bindingOperation.setOperation(operation);
SOAPBody soapBody = new SOAPBodyImpl();
soapBody.setUse("literal");
soapBody.setNamespaceURI(TNS);
soapBody.setEncodingStyles(UtilMisc.toList("http://schemas.xmlsoap.org/soap/encoding/"));
BindingOutput bindingOutput = def.createBindingOutput();
bindingOutput.addExtensibilityElement(soapBody);
bindingOperation.setBindingOutput(bindingOutput);
BindingInput bindingInput = def.createBindingInput();
bindingInput.addExtensibilityElement(soapBody);
bindingOperation.setBindingInput(bindingInput);
SOAPOperation soapOperation = new SOAPOperationImpl();
// soapAction should be set to the location of the SOAP URI, or Visual Studio won't construct the correct SOAP message
soapOperation.setSoapActionURI(locationURI);
// this is the RPC/literal style. See http://www.ibm.com/developerworks/webservices/library/ws-whichwsdl/
// this parameter is necessary or Apache Synapse won't recognize the WSDL
soapOperation.setStyle("rpc");
bindingOperation.addExtensibilityElement(soapOperation);
binding.addBindingOperation(bindingOperation);
def.addBinding(binding);
// Service port
Port port = def.createPort();
port.setBinding(binding);
port.setName(this.name + "Port");
if (locationURI != null) {
SOAPAddress soapAddress = new SOAPAddressImpl();
soapAddress.setLocationURI(locationURI);
port.addExtensibilityElement(soapAddress);
}
Service service = def.createService();
service.setQName(new QName(TNS, this.name));
service.addPort(port);
def.addService(service);
}
use of javax.wsdl.extensions.soap.SOAPOperation in project cxf by apache.
the class PartialWSDLProcessor method setSoapOperationExtElement.
private static void setSoapOperationExtElement(BindingOperation bo, ExtensionRegistry extReg) throws Exception {
SOAPOperation soapOperation = SOAPBindingUtil.createSoapOperation(extReg, false);
soapOperation.setStyle(style);
soapOperation.setSoapActionURI("");
bo.addExtensibilityElement(soapOperation);
}
use of javax.wsdl.extensions.soap.SOAPOperation in project cxf by apache.
the class WSDLToSoapProcessorTest method testWithoutBinding.
@Test
public void testWithoutBinding() throws Exception {
String[] args = new String[] { "-i", "Greeter", "-b", "Greeter_SOAPBinding", "-d", output.getCanonicalPath(), "-o", "hello_world_soap_newbinding.wsdl", getLocation("/misctools_wsdl/hello_world_nobinding.wsdl") };
WSDLToSoap.main(args);
File outputFile = new File(output, "hello_world_soap_newbinding.wsdl");
assertTrue("New wsdl file is not generated", outputFile.exists());
assertTrue("Generated file is empty!", outputFile.length() > 0);
WSDLToSoapProcessor processor = new WSDLToSoapProcessor();
processor.setEnvironment(env);
try {
processor.parseWSDL(outputFile.getAbsolutePath());
Binding binding = processor.getWSDLDefinition().getBinding(new QName(processor.getWSDLDefinition().getTargetNamespace(), "Greeter_SOAPBinding"));
if (binding == null) {
fail("Element wsdl:binding Greeter_SOAPBinding_NewBinding Missed!");
}
for (Object obj : binding.getExtensibilityElements()) {
assertTrue(SOAPBindingUtil.isSOAPBinding(obj));
assertTrue(obj instanceof SOAPBinding);
SoapBinding soapBinding = SOAPBindingUtil.getSoapBinding(obj);
assertNotNull(soapBinding);
assertTrue("document".equalsIgnoreCase(soapBinding.getStyle()));
assertTrue(WSDLConstants.NS_SOAP11_HTTP_TRANSPORT.equalsIgnoreCase(soapBinding.getTransportURI()));
}
BindingOperation bo = binding.getBindingOperation("sayHi", null, null);
if (bo == null) {
fail("Element <wsdl:operation name=\"sayHi\"> Missed!");
}
for (Object obj : bo.getExtensibilityElements()) {
assertTrue(SOAPBindingUtil.isSOAPOperation(obj));
assertTrue(obj instanceof SOAPOperation);
SoapOperation soapOperation = SOAPBindingUtil.getSoapOperation(obj);
assertNotNull(soapOperation);
assertTrue("document".equalsIgnoreCase(soapOperation.getStyle()));
}
BindingInput bi = bo.getBindingInput();
for (Object obj : bi.getExtensibilityElements()) {
assertTrue(SOAPBindingUtil.isSOAPBody(obj));
assertTrue(obj instanceof SOAPBody);
SoapBody soapBody = SOAPBindingUtil.getSoapBody(obj);
assertNotNull(soapBody);
assertTrue("literal".equalsIgnoreCase(soapBody.getUse()));
}
} catch (ToolException e) {
fail("Exception Encountered when parsing wsdl, error: " + e.getMessage());
}
}
use of javax.wsdl.extensions.soap.SOAPOperation in project tesb-studio-se by Talend.
the class ComponentBuilder method populateComponent.
private static ServiceInfo populateComponent(Service service) {
ServiceInfo serviceInfo = new ServiceInfo();
serviceInfo.setServiceName(service.getQName());
Collection<Port> ports = service.getPorts().values();
for (Port port : ports) {
String soapLocation = null;
SOAPAddress soapAddress = findExtensibilityElement(port.getExtensibilityElements(), SOAPAddress.class);
if (null != soapAddress) {
soapLocation = soapAddress.getLocationURI();
} else {
SOAP12Address soap12Address = findExtensibilityElement(port.getExtensibilityElements(), SOAP12Address.class);
if (null != soap12Address) {
soapLocation = soap12Address.getLocationURI();
}
}
Binding binding = port.getBinding();
for (BindingOperation operation : (Collection<BindingOperation>) binding.getBindingOperations()) {
SOAPOperation soapOperation = findExtensibilityElement(operation.getExtensibilityElements(), SOAPOperation.class);
OperationInfo operationInfo = new OperationInfo(operation.getOperation());
operationInfo.setPortName(port.getName());
operationInfo.setNamespaceURI(binding.getPortType().getQName().getNamespaceURI());
if (soapOperation != null) {
operationInfo.setSoapActionURI(soapOperation.getSoapActionURI());
} else {
SOAP12Operation soap12Operation = findExtensibilityElement(operation.getExtensibilityElements(), SOAP12Operation.class);
if (soap12Operation != null) {
operationInfo.setSoapActionURI(soap12Operation.getSoapActionURI());
}
}
operationInfo.setTargetURL(soapLocation);
serviceInfo.addOperation(operationInfo);
}
}
return serviceInfo;
}
Aggregations