use of com.helger.phase4.soap12.Soap12Body in project eclipselink by eclipse-ee4j.
the class WSDLGenerator method createMethodDefinition.
private void createMethodDefinition(WSDLFactory factory, ExtensionRegistry registry, Definition def, Operation operation, boolean useSOAP12) throws WSDLException {
Message requestMessage = def.createMessage();
requestMessage.setUndefined(false);
requestMessage.setQName(new QName(serviceNameSpace, operation.getName() + REQUEST_SUFFIX));
Part requestPart = def.createPart();
requestPart.setName(operation.getName() + REQUEST_SUFFIX);
requestPart.setElementName(new QName(serviceNameSpace, operation.getName()));
requestMessage.addPart(requestPart);
def.addMessage(requestMessage);
Message responseMessage = null;
if (operation.hasResponse()) {
responseMessage = def.createMessage();
responseMessage.setUndefined(false);
responseMessage.setQName(new QName(serviceNameSpace, operation.getName() + RESPONSE_SUFFIX));
Part responsePart = def.createPart();
responsePart.setName(operation.getName() + RESPONSE_SUFFIX);
responsePart.setElementName(new QName(serviceNameSpace, operation.getName() + RESPONSE_SUFFIX));
responseMessage.addPart(responsePart);
def.addMessage(responseMessage);
}
PortType portType = def.getPortType(new QName(serviceNameSpace, serviceName + PORT_SUFFIX));
javax.wsdl.Operation op = def.createOperation();
op.setUndefined(false);
op.setName(operation.getName());
Input input = def.createInput();
input.setMessage(requestMessage);
op.setInput(input);
if (operation.hasResponse()) {
Output output = def.createOutput();
output.setMessage(responseMessage);
op.setOutput(output);
}
portType.addOperation(op);
Binding binding = def.getBinding(new QName(serviceNameSpace, serviceName + BINDING_SUFFIX));
BindingOperation bop = def.createBindingOperation();
bop.setName(operation.getName());
ExtensibilityElement so = null;
if (useSOAP12) {
so = registry.createExtension(BindingOperation.class, new QName(SOAP_12_NAMESPACE_URI, TAG_SOAP_OPERATION));
((SOAP12Operation) so).setSoapActionURI(serviceNameSpace + ":" + op.getName());
} else {
so = registry.createExtension(BindingOperation.class, new QName(SOAP_11_NAMESPACE_URI, TAG_SOAP_OPERATION));
((SOAPOperation) so).setSoapActionURI(serviceNameSpace + ":" + op.getName());
}
bop.addExtensibilityElement(so);
BindingInput bi = def.createBindingInput();
ExtensibilityElement soapInputBody = null;
if (useSOAP12) {
soapInputBody = registry.createExtension(BindingInput.class, new QName(SOAP_12_NAMESPACE_URI, TAG_SOAP_BODY));
((SOAP12Body) soapInputBody).setUse(SOAP_USE);
} else {
soapInputBody = registry.createExtension(BindingInput.class, new QName(SOAP_11_NAMESPACE_URI, TAG_SOAP_BODY));
((SOAPBody) soapInputBody).setUse(SOAP_USE);
}
bi.addExtensibilityElement(soapInputBody);
bop.setBindingInput(bi);
if (operation.hasResponse()) {
BindingOutput bo = def.createBindingOutput();
ExtensibilityElement soapOutputBody = null;
if (useSOAP12) {
soapOutputBody = registry.createExtension(BindingOutput.class, new QName(SOAP_12_NAMESPACE_URI, TAG_SOAP_BODY));
((SOAP12Body) soapOutputBody).setUse(SOAP_USE);
} else {
soapOutputBody = registry.createExtension(BindingOutput.class, new QName(SOAP_11_NAMESPACE_URI, TAG_SOAP_BODY));
((SOAPBody) soapOutputBody).setUse(SOAP_USE);
}
bo.addExtensibilityElement(soapOutputBody);
bop.setBindingOutput(bo);
}
if (!(operation instanceof QueryOperation)) {
// non-QueryOperations don't have Responses, but the fault requirements
// mean we have to create 'dummy' WSDL outputs
BindingOutput bo = def.createBindingOutput();
ExtensibilityElement soapOutputBody = null;
if (useSOAP12) {
soapOutputBody = registry.createExtension(BindingOutput.class, new QName(SOAP_12_NAMESPACE_URI, TAG_SOAP_BODY));
((SOAP12Body) soapOutputBody).setUse(SOAP_USE);
} else {
soapOutputBody = registry.createExtension(BindingOutput.class, new QName(SOAP_11_NAMESPACE_URI, TAG_SOAP_BODY));
((SOAPBody) soapOutputBody).setUse(SOAP_USE);
}
bo.addExtensibilityElement(soapOutputBody);
bop.setBindingOutput(bo);
// add WSDL fault to binding operations
BindingFault bindingFault = def.createBindingFault();
String exceptionName = FAULT_SUFFIX + EXCEPTION_SUFFIX;
bindingFault.setName(exceptionName);
ExtensibilityElement soapFaultBody = null;
if (useSOAP12) {
soapFaultBody = registry.createExtension(BindingFault.class, new QName(SOAP_12_NAMESPACE_URI, TAG_SOAP_FAULT));
((SOAP12Fault) soapFaultBody).setUse(SOAP_USE);
((SOAP12Fault) soapFaultBody).setName(exceptionName);
} else {
soapFaultBody = registry.createExtension(BindingFault.class, new QName(SOAP_11_NAMESPACE_URI, TAG_SOAP_FAULT));
((SOAPFault) soapFaultBody).setUse(SOAP_USE);
((SOAPFault) soapFaultBody).setName(exceptionName);
}
bindingFault.addExtensibilityElement(soapFaultBody);
bop.addBindingFault(bindingFault);
Message emptyResponseMessage = def.getMessage(new QName(serviceNameSpace, EMPTY_RESPONSE));
Output output = def.createOutput();
output.setName(operation.getName() + EMPTY_RESPONSE);
output.setMessage(emptyResponseMessage);
op.setOutput(output);
Message faultMessage = def.getMessage(new QName(serviceNameSpace, FAULT_SUFFIX + TYPE_SUFFIX));
Fault fault = def.createFault();
fault.setMessage(faultMessage);
fault.setName(exceptionName);
op.addFault(fault);
}
binding.addBindingOperation(bop);
}
use of com.helger.phase4.soap12.Soap12Body in project phase4 by phax.
the class AbstractAS4Message method getAsSoapDocument.
@Nonnull
public final Document getAsSoapDocument(@Nullable final Node aPayload) {
// Convert to DOM Node
final Document aEbms3Document = Ebms3WriterBuilder.ebms3Messaging().getAsDocument(m_aMessaging);
if (aEbms3Document == null)
throw new IllegalStateException("Failed to write EBMS3 Messaging to XML");
final Node aRealPayload = aPayload instanceof Document ? ((Document) aPayload).getDocumentElement() : aPayload;
switch(m_eSoapVersion) {
case SOAP_11:
{
// Creating SOAP 11 Envelope
final Soap11Envelope aSoapEnv = new Soap11Envelope();
aSoapEnv.setHeader(new Soap11Header());
aSoapEnv.setBody(new Soap11Body());
aSoapEnv.getHeader().addAny(aEbms3Document.getDocumentElement());
if (aRealPayload != null)
aSoapEnv.getBody().addAny(aRealPayload);
return Ebms3WriterBuilder.soap11().getAsDocument(aSoapEnv);
}
case SOAP_12:
{
// Creating SOAP 12 Envelope
final Soap12Envelope aSoapEnv = new Soap12Envelope();
aSoapEnv.setHeader(new Soap12Header());
aSoapEnv.setBody(new Soap12Body());
aSoapEnv.getHeader().addAny(aEbms3Document.getDocumentElement());
if (aRealPayload != null)
aSoapEnv.getBody().addAny(aRealPayload);
return Ebms3WriterBuilder.soap12().getAsDocument(aSoapEnv);
}
default:
throw new IllegalStateException("Unsupported SOAP version " + m_eSoapVersion);
}
}
use of com.helger.phase4.soap12.Soap12Body in project phase4 by phax.
the class Ebms3MessagingTest method _getMessagingAsSoapDocument.
@Nullable
private Document _getMessagingAsSoapDocument(@Nonnull final Ebms3Messaging aEbms3Messaging) {
final Document aEbms3Document = Ebms3WriterBuilder.ebms3Messaging().getAsDocument(aEbms3Messaging);
if (aEbms3Document == null)
throw new IllegalStateException("Failed to write EBMS3 Messaging to XML");
// Creating SOAP 12 Envelope
final Soap12Envelope aSoapEnv = new Soap12Envelope();
aSoapEnv.setHeader(new Soap12Header());
aSoapEnv.setBody(new Soap12Body());
aSoapEnv.getHeader().addAny(aEbms3Document.getDocumentElement());
return Ebms3WriterBuilder.soap12().getAsDocument(aSoapEnv);
}
use of com.helger.phase4.soap12.Soap12Body in project tdi-studio-se by Talend.
the class ComponentBuilder method buildOperation.
private OperationInfo buildOperation(OperationInfo operationInfo, BindingOperation bindingOper) {
Operation oper = bindingOper.getOperation();
operationInfo.setTargetMethodName(oper.getName());
Vector operElems = findExtensibilityElement(bindingOper.getExtensibilityElements(), "operation");
ExtensibilityElement operElem = (ExtensibilityElement) operElems.elementAt(0);
if (operElem != null && operElem instanceof SOAPOperation) {
SOAPOperation soapOperation = (SOAPOperation) operElem;
operationInfo.setSoapActionURI(soapOperation.getSoapActionURI());
} else if (operElem != null && operElem instanceof SOAP12Operation) {
SOAP12Operation soapOperation = (SOAP12Operation) operElem;
operationInfo.setSoapActionURI(soapOperation.getSoapActionURI());
}
BindingInput bindingInput = bindingOper.getBindingInput();
BindingOutput bindingOutput = bindingOper.getBindingOutput();
Vector bodyElems = findExtensibilityElement(bindingInput.getExtensibilityElements(), "body");
ExtensibilityElement bodyElem = (ExtensibilityElement) bodyElems.elementAt(0);
if (bodyElem != null && bodyElem instanceof SOAPBody) {
SOAPBody soapBody = (SOAPBody) bodyElem;
List styles = soapBody.getEncodingStyles();
String encodingStyle = null;
if (styles != null) {
encodingStyle = styles.get(0).toString();
}
if (encodingStyle == null) {
encodingStyle = DEFAULT_SOAP_ENCODING_STYLE;
}
operationInfo.setEncodingStyle(encodingStyle.toString());
operationInfo.setTargetObjectURI(soapBody.getNamespaceURI());
} else if (bodyElem != null && bodyElem instanceof SOAP12Body) {
SOAP12Body soapBody = (SOAP12Body) bodyElem;
String encodingStyle = null;
if (soapBody.getEncodingStyle() != null) {
encodingStyle = soapBody.getEncodingStyle().toString();
}
if (encodingStyle == null) {
encodingStyle = DEFAULT_SOAP_ENCODING_STYLE;
}
operationInfo.setEncodingStyle(encodingStyle.toString());
operationInfo.setTargetObjectURI(soapBody.getNamespaceURI());
}
Input inDef = oper.getInput();
if (inDef != null) {
Message inMsg = inDef.getMessage();
if (inMsg != null) {
operationInfo.setInputMessageName(inMsg.getQName().getLocalPart());
getParameterFromMessage(operationInfo, inMsg, 1);
operationInfo.setInmessage(inMsg);
}
}
Output outDef = oper.getOutput();
if (outDef != null) {
Message outMsg = outDef.getMessage();
if (outMsg != null) {
operationInfo.setOutputMessageName(outMsg.getQName().getLocalPart());
getParameterFromMessage(operationInfo, outMsg, 2);
operationInfo.setOutmessage(outMsg);
}
}
return operationInfo;
}
use of com.helger.phase4.soap12.Soap12Body in project cxf by apache.
the class WSDLToSoapProcessorTest method testNewSoap12Binding.
@Test
public void testNewSoap12Binding() throws Exception {
String[] args = new String[] { "-i", "Greeter", "-soap12", "-b", "Greeter_SOAP12Binding", "-d", output.getCanonicalPath(), "-o", "hello_world_soap12_newbinding.wsdl", getLocation("/misctools_wsdl/hello_world_soap12_nobinding.wsdl") };
WSDLToSoap.main(args);
File outputFile = new File(output, "hello_world_soap12_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_SOAP12Binding"));
if (binding == null) {
fail("Element wsdl:binding Greeter_SOAPBinding_NewBinding Missed!");
}
for (Object obj : binding.getExtensibilityElements()) {
assertTrue(SOAPBindingUtil.isSOAPBinding(obj));
assertTrue(obj instanceof SOAP12Binding);
SoapBinding soapBinding = SOAPBindingUtil.getSoapBinding(obj);
assertNotNull(soapBinding);
assertTrue("document".equalsIgnoreCase(soapBinding.getStyle()));
assertTrue(WSDLConstants.NS_SOAP_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 SOAP12Operation);
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 SOAP12Body);
SoapBody soapBody = SOAPBindingUtil.getSoapBody(obj);
assertNotNull(soapBody);
assertTrue("literal".equalsIgnoreCase(soapBody.getUse()));
}
} catch (ToolException e) {
fail("Exception Encountered when parsing wsdl, error: " + e.getMessage());
}
}
Aggregations