use of javax.wsdl.BindingInput 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 javax.wsdl.BindingInput 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.BindingInput in project cxf by apache.
the class WSDLToCorbaBinding method addBindingOperations.
private void addBindingOperations(Definition definition, PortType portType, Binding binding) throws Exception {
List<Operation> ops = CastUtils.cast(portType.getOperations());
for (Operation op : ops) {
try {
BindingOperation bindingOperation = definition.createBindingOperation();
addCorbaOperationExtElement(bindingOperation, op);
bindingOperation.setName(op.getName());
if (op.getInput() != null) {
BindingInput bindingInput = definition.createBindingInput();
bindingInput.setName(op.getInput().getName());
bindingOperation.setBindingInput(bindingInput);
}
if (op.getOutput() != null) {
BindingOutput bindingOutput = definition.createBindingOutput();
bindingOutput.setName(op.getOutput().getName());
bindingOperation.setBindingOutput(bindingOutput);
}
// add Faults
if (op.getFaults() != null && op.getFaults().size() > 0) {
Collection<Fault> faults = CastUtils.cast(op.getFaults().values());
for (Fault fault : faults) {
BindingFault bindingFault = definition.createBindingFault();
bindingFault.setName(fault.getName());
bindingOperation.addBindingFault(bindingFault);
}
}
bindingOperation.setOperation(op);
binding.addBindingOperation(bindingOperation);
} catch (Exception ex) {
LOG.warning("Operation " + op.getName() + " not mapped to CORBA binding.");
}
}
}
use of javax.wsdl.BindingInput in project cxf by apache.
the class OperationVisitor method generateInputMessage.
public Message generateInputMessage(Operation operation, BindingOperation bindingOperation) {
Message msg = definition.createMessage();
QName msgName;
if (!mapper.isDefaultMapping()) {
// mangle the message name
// REVISIT, do we put in the entire scope for mangling
msgName = new QName(definition.getTargetNamespace(), getScope().tail() + "." + operation.getName());
} else {
msgName = new QName(definition.getTargetNamespace(), operation.getName());
}
msg.setQName(msgName);
msg.setUndefined(false);
String inputName = operation.getName() + REQUEST_SUFFIX;
Input input = definition.createInput();
input.setName(inputName);
input.setMessage(msg);
BindingInput bindingInput = definition.createBindingInput();
bindingInput.setName(inputName);
bindingOperation.setBindingInput(bindingInput);
operation.setInput(input);
definition.addMessage(msg);
return msg;
}
use of javax.wsdl.BindingInput in project cxf by apache.
the class PartialWSDLProcessor method getBindingInput.
private static BindingInput getBindingInput(Input input, Definition wsdlDefinition, ExtensionRegistry extReg) throws Exception {
BindingInput bi = wsdlDefinition.createBindingInput();
bi.setName(input.getName());
bi.addExtensibilityElement(getSoapBody(BindingInput.class, extReg));
return bi;
}
Aggregations