use of org.apache.cxf.binding.soap.wsdl.extensions.SoapOperation in project cxf by apache.
the class WSDLToSoapProcessorTest method testDocLitWithFault.
@Test
public void testDocLitWithFault() throws Exception {
String[] args = new String[] { "-i", "Greeter", "-d", output.getCanonicalPath(), getLocation("/misctools_wsdl/hello_world_doc_lit.wsdl") };
WSDLToSoap.main(args);
File outputFile = new File(output, "hello_world_doc_lit-soapbinding.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_Binding"));
if (binding == null) {
fail("Element wsdl:binding Greeter_Binding Missed!");
}
boolean found = false;
for (Object obj : binding.getExtensibilityElements()) {
SoapBinding soapBinding = SOAPBindingUtil.getSoapBinding(obj);
if (soapBinding != null && soapBinding.getStyle().equalsIgnoreCase("document")) {
found = true;
break;
}
}
if (!found) {
fail("Element soap:binding Missed!");
}
BindingOperation bo = binding.getBindingOperation("pingMe", null, null);
if (bo == null) {
fail("Element <wsdl:operation name=\"pingMe\"> Missed!");
}
found = false;
for (Object obj : bo.getExtensibilityElements()) {
SoapOperation soapOperation = SOAPBindingUtil.getSoapOperation(obj);
if (soapOperation != null && soapOperation.getStyle().equalsIgnoreCase("document")) {
found = true;
break;
}
}
if (!found) {
fail("Element soap:operation Missed!");
}
BindingFault fault = bo.getBindingFault("pingMeFault");
if (fault == null) {
fail("Element <wsdl:fault name=\"pingMeFault\"> Missed!");
}
found = false;
for (Object obj : fault.getExtensibilityElements()) {
if (SOAPBindingUtil.isSOAPFault(obj)) {
found = true;
break;
}
}
if (!found) {
fail("Element soap:fault Missed!");
}
List<SoapFault> faults = SOAPBindingUtil.getBindingOperationSoapFaults(bo);
assertEquals(1, faults.size());
assertEquals("pingMeFault", faults.get(0).getName());
} catch (ToolException e) {
fail("Exception Encountered when parsing wsdl, error: " + e.getMessage());
}
}
use of org.apache.cxf.binding.soap.wsdl.extensions.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 org.apache.cxf.binding.soap.wsdl.extensions.SoapOperation 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.SoapOperation 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.SoapOperation in project cxf by apache.
the class SoapBindingFactory method initializeBindingOperation.
private void initializeBindingOperation(SoapBindingInfo bi, BindingOperationInfo boi) {
SoapOperationInfo soi = new SoapOperationInfo();
SoapOperation soapOp = SOAPBindingUtil.getSoapOperation(boi.getExtensors(ExtensibilityElement.class));
if (soapOp != null) {
String action = soapOp.getSoapActionURI();
if (action == null) {
action = "";
}
soi.setAction(action);
soi.setStyle(soapOp.getStyle());
}
boi.addExtensor(soi);
if (boi.getInput() != null) {
initializeMessage(bi, boi, boi.getInput());
}
if (boi.getOutput() != null) {
initializeMessage(bi, boi, boi.getOutput());
}
}
Aggregations