use of javax.wsdl.BindingInput in project cxf by apache.
the class JAXWSDefinitionBuilderTest method testBuildDefinitionWithXMLBinding.
@Test
public void testBuildDefinitionWithXMLBinding() {
String qname = "http://apache.org/hello_world_xml_http/bare";
String wsdlUrl = getClass().getResource("resources/hello_world_xml_bare.wsdl").toString();
JAXWSDefinitionBuilder builder = new JAXWSDefinitionBuilder();
builder.setBus(BusFactory.getDefaultBus());
builder.setContext(env);
Definition def = builder.build(wsdlUrl);
assertNotNull(def);
Map<?, ?> services = def.getServices();
assertNotNull(services);
assertEquals(1, services.size());
Service service = (Service) services.get(new QName(qname, "XMLService"));
assertNotNull(service);
Map<?, ?> ports = service.getPorts();
assertNotNull(ports);
assertEquals(1, ports.size());
Port port = service.getPort("XMLPort");
assertNotNull(port);
assertEquals(1, port.getExtensibilityElements().size());
Object obj = port.getExtensibilityElements().get(0);
if (obj instanceof JAXBExtensibilityElement) {
obj = ((JAXBExtensibilityElement) obj).getValue();
}
assertTrue(obj.getClass().getName() + " is not an AddressType", obj instanceof AddressType);
Binding binding = port.getBinding();
assertNotNull(binding);
assertEquals(new QName(qname, "Greeter_XMLBinding"), binding.getQName());
BindingOperation operation = binding.getBindingOperation("sayHi", null, null);
assertNotNull(operation);
BindingInput input = operation.getBindingInput();
assertNotNull(input);
assertEquals(1, input.getExtensibilityElements().size());
obj = input.getExtensibilityElements().get(0);
if (obj instanceof JAXBExtensibilityElement) {
obj = ((JAXBExtensibilityElement) obj).getValue();
}
assertTrue(obj.getClass().getName() + " is not an XMLBindingMessageFormat", obj instanceof XMLBindingMessageFormat);
}
use of javax.wsdl.BindingInput in project cxf by apache.
the class WSDLToSoapProcessor method getBindingInput.
private BindingInput getBindingInput(Input input) throws ToolException {
BindingInput bi = wsdlDefinition.createBindingInput();
bi.setName(input.getName());
// As command line won't specify the details of body/header for message
// parts
// All input message's parts will be added into one soap body element
bi.addExtensibilityElement(getSoapBody(BindingInput.class));
return bi;
}
use of javax.wsdl.BindingInput 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());
}
}
use of javax.wsdl.BindingInput in project cxf by apache.
the class WSDLToSoapProcessorTest method testAddSoap12Binding.
@Test
public void testAddSoap12Binding() 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.wsdl") };
WSDLToSoap.main(args);
File outputFile = new File(output, "hello_world_soap12_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_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()));
}
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()));
}
bo = binding.getBindingOperation("pingMe", null, null);
assertNotNull(bo);
Iterator<?> it = bo.getExtensibilityElements().iterator();
assertTrue(it != null && it.hasNext());
assertTrue(it.next() instanceof SOAP12Operation);
it = bo.getBindingInput().getExtensibilityElements().iterator();
assertTrue(it != null && it.hasNext());
assertTrue(it.next() instanceof SOAP12Body);
it = bo.getBindingOutput().getExtensibilityElements().iterator();
assertTrue(it != null && it.hasNext());
assertTrue(it.next() instanceof SOAP12Body);
Map<?, ?> faults = bo.getBindingFaults();
assertTrue(faults != null && faults.size() == 1);
Object bf = faults.get("pingMeFault");
assertNotNull(bf);
assertTrue(bf instanceof BindingFault);
assertEquals("pingMeFault", ((BindingFault) bf).getName());
} catch (ToolException e) {
fail("Exception Encountered when parsing wsdl, error: " + e.getMessage());
}
}
use of javax.wsdl.BindingInput 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());
}
}
Aggregations