use of org.apache.cxf.binding.soap.wsdl.extensions.SoapBinding in project cxf by apache.
the class WSDLToSoapProcessorTest method testRpcLitWithoutFault.
@Test
public void testRpcLitWithoutFault() throws Exception {
String[] args = new String[] { "-i", "GreeterRPCLit", "-n", "http://apache.org/hello_world_rpclit_test", "-b", "Greeter_SOAPBinding_NewBinding", "-style", "rpc", "-use", "literal", "-d", output.getCanonicalPath(), "-o", "hello_world_rpc_lit_newbinding.wsdl", getLocation("/misctools_wsdl/hello_world_rpc_lit.wsdl") };
WSDLToSoap.main(args);
File outputFile = new File(output, "hello_world_rpc_lit_newbinding.wsdl");
assertTrue("New wsdl file is not generated", outputFile.exists());
WSDLToSoapProcessor processor = new WSDLToSoapProcessor();
processor.setEnvironment(env);
try {
processor.parseWSDL(outputFile.getAbsolutePath());
Binding binding = processor.getWSDLDefinition().getBinding(new QName(processor.getWSDLDefinition().getTargetNamespace(), "Greeter_SOAPBinding_NewBinding"));
if (binding == null) {
fail("Element wsdl:binding Greeter_SOAPBinding_NewBinding Missed!");
}
boolean found = false;
for (Object obj : binding.getExtensibilityElements()) {
SoapBinding soapBinding = SOAPBindingUtil.getSoapBinding(obj);
if (soapBinding != null && soapBinding.getStyle().equalsIgnoreCase("rpc")) {
found = true;
break;
}
}
if (!found) {
fail("Element soap:binding style=rpc Missed!");
}
BindingOperation bo = binding.getBindingOperation("sendReceiveData", null, null);
if (bo == null) {
fail("Element <wsdl:operation name=\"sendReceiveData\"> Missed!");
}
found = false;
for (Object obj : bo.getExtensibilityElements()) {
SoapOperation soapOperation = SOAPBindingUtil.getSoapOperation(obj);
if (soapOperation != null && soapOperation.getStyle().equalsIgnoreCase("rpc")) {
found = true;
break;
}
}
if (!found) {
fail("Element soap:operation style=rpc Missed!");
}
BindingInput bi = bo.getBindingInput();
found = false;
for (Object obj : bi.getExtensibilityElements()) {
SoapBody soapBody = SOAPBindingUtil.getSoapBody(obj);
if (soapBody != null && soapBody.getUse().equalsIgnoreCase("literal")) {
found = true;
break;
}
}
if (!found) {
fail("Element soap:body use=literal Missed!");
}
} catch (ToolException e) {
fail("Exception Encountered when parsing wsdl, error: " + e.getMessage());
}
}
use of org.apache.cxf.binding.soap.wsdl.extensions.SoapBinding in project cxf by apache.
the class SOAPBindingUtil method isMixedStyle.
public static boolean isMixedStyle(Binding binding) {
String bindingStyle = "";
String previousOpStyle = "";
String style = "";
for (Object obj : binding.getExtensibilityElements()) {
if (isSOAPBinding(obj)) {
SoapBinding soapBinding = getSoapBinding(obj);
bindingStyle = soapBinding.getStyle();
if (bindingStyle == null) {
bindingStyle = "";
}
}
}
for (Object bobj : binding.getBindingOperations()) {
BindingOperation bop = (BindingOperation) bobj;
for (Object obj : bop.getExtensibilityElements()) {
if (isSOAPOperation(obj)) {
SoapOperation soapOperation = getSoapOperation(obj);
style = soapOperation.getStyle();
if (style == null) {
style = "";
}
if ("".equals(bindingStyle) && "".equals(previousOpStyle) || "".equals(bindingStyle) && previousOpStyle.equalsIgnoreCase(style)) {
previousOpStyle = style;
} else if (!"".equals(bindingStyle) && "".equals(previousOpStyle) && bindingStyle.equalsIgnoreCase(style) || bindingStyle.equalsIgnoreCase(previousOpStyle) && bindingStyle.equalsIgnoreCase(style)) {
previousOpStyle = style;
} else if (!"".equals(bindingStyle) && "".equals(style) && "".equals(previousOpStyle)) {
continue;
} else {
return true;
}
}
}
}
return false;
}
use of org.apache.cxf.binding.soap.wsdl.extensions.SoapBinding in project cxf by apache.
the class SOAPBindingUtil method createSoapBinding.
public static SoapBinding createSoapBinding(ExtensionRegistry extReg, boolean isSOAP12) throws WSDLException {
ExtensibilityElement extElement = null;
if (isSOAP12) {
extElement = extReg.createExtension(Binding.class, new QName(WSDLConstants.NS_SOAP12, "binding"));
((SOAP12Binding) extElement).setTransportURI(WSDLConstants.NS_SOAP_HTTP_TRANSPORT);
} else {
extElement = extReg.createExtension(Binding.class, new QName(WSDLConstants.NS_SOAP11, "binding"));
((SOAPBinding) extElement).setTransportURI(WSDLConstants.NS_SOAP_HTTP_TRANSPORT);
}
return getSoapBinding(extElement);
}
Aggregations