use of javax.wsdl.extensions.soap.SOAPBody in project carbon-business-process by wso2.
the class SOAPHelper method createSoapRequest.
public void createSoapRequest(MessageContext msgCtx, Element message, Operation op) throws AxisFault {
if (op == null) {
throw new NullPointerException("Null operation");
}
// The message can be null if the input message has no part
if (op.getInput().getMessage().getParts().size() > 0 && message == null) {
throw new NullPointerException("Null message.");
}
if (msgCtx == null) {
throw new NullPointerException("Null msgCtx");
}
BindingOperation bop = binding.getBindingOperation(op.getName(), null, null);
if (bop == null) {
throw new OdeFault("BindingOperation not found.");
}
BindingInput bi = bop.getBindingInput();
if (bi == null) {
throw new OdeFault("BindingInput not found.");
}
SOAPEnvelope soapEnv = msgCtx.getEnvelope();
if (soapEnv == null) {
soapEnv = soapFactory.getDefaultEnvelope();
msgCtx.setEnvelope(soapEnv);
}
// createSoapHeaders(soapEnv, getSOAPHeaders(bi), op.getInput().getMessage(), message);
SOAPBody soapBody = getSOAPBody(bi);
if (soapBody != null) {
org.apache.axiom.soap.SOAPBody sb = soapEnv.getBody() == null ? soapFactory.createSOAPBody(soapEnv) : soapEnv.getBody();
createSoapBody(sb, soapBody, op.getInput().getMessage(), message, op.getName());
}
}
use of javax.wsdl.extensions.soap.SOAPBody 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.SOAPBody in project tomee by apache.
the class JaxRpcServiceInfoBuilder method getStyle.
private BindingStyle getStyle(Binding binding) throws OpenEJBException {
SOAPBinding soapBinding = getExtensibilityElement(SOAPBinding.class, binding.getExtensibilityElements());
String styleString = soapBinding.getStyle();
BindingInput bindingInput = ((BindingOperation) binding.getBindingOperations().get(0)).getBindingInput();
SOAPBody soapBody = getExtensibilityElement(SOAPBody.class, bindingInput.getExtensibilityElements());
String useString = soapBody.getUse();
BindingStyle bindingStyle = BindingStyle.getBindingStyle(styleString, useString);
return bindingStyle;
}
use of javax.wsdl.extensions.soap.SOAPBody in project tomee by apache.
the class LightWeightMappingValidator method visit.
@Override
protected void visit(BindingOutput bindingOutput) {
SOAPBody body = getSOAPBody(bindingOutput.getExtensibilityElements());
String encoding = body.getUse();
if (encoding == null || !encoding.equals("encoded")) {
context.addFailure(new ValidationFailure("The use attribute of the binding output operation must be 'encoded': " + bindingOutput.getName()));
}
}
use of javax.wsdl.extensions.soap.SOAPBody in project tomee by apache.
the class LightWeightMappingValidator method visit.
@Override
protected void visit(BindingInput bindingInput) {
SOAPBody body = getSOAPBody(bindingInput.getExtensibilityElements());
String encoding = body.getUse();
if (encoding == null || !encoding.equals("encoded")) {
context.addFailure(new ValidationFailure("The use attribute of the binding input operation must be 'encoded': " + bindingInput.getName()));
}
}
Aggregations