public static final String STYLE_RPC = "rpc";
public static final String STYLE_DOCUMENT = "document";
public static Wsdl1SoapBinding createWsdl1SoapBinding(Port wsdlPort) {
Wsdl1SoapBindingImpl binding = new Wsdl1SoapBindingImpl(Soap12.getInstance());
// Find infos from port
for (Iterator iter = wsdlPort.getExtensibilityElements().iterator(); iter.hasNext();) {
ExtensibilityElement element = (ExtensibilityElement) iter.next();
if (element instanceof SOAP12Address) {
SOAP12Address soapAddress = (SOAP12Address) element;
binding.setLocationURI(soapAddress.getLocationURI());
} else {
//throw new IllegalStateException("Unrecognized extension: " + QNameUtil.toString(element.getElementType()));
}
}
javax.wsdl.Binding wsdlBinding = wsdlPort.getBinding();
for (Iterator iter = wsdlBinding.getExtensibilityElements().iterator(); iter.hasNext();) {
ExtensibilityElement element = (ExtensibilityElement) iter.next();
if (element instanceof SOAP12Binding) {
SOAP12Binding soapBinding = (SOAP12Binding) element;
binding.setTransportURI(soapBinding.getTransportURI());
binding.setStyle(getStyle(soapBinding.getStyle()));
} else {
//throw new IllegalStateException("Unrecognized extension: " + QNameUtil.toString(element.getElementType()));
}
}
PortType wsdlPortType = wsdlBinding.getPortType();
for (Iterator iter = wsdlPortType.getOperations().iterator(); iter.hasNext();) {
Operation wsdlOperation = (Operation) iter.next();
BindingOperation wsdlBindingOperation = wsdlBinding.getBindingOperation(wsdlOperation.getName(), null, null);
SOAP12Operation wsdlSoapOperation = WSDLUtils.getExtension(wsdlBindingOperation, SOAP12Operation.class);
Wsdl1SoapOperationImpl operation = new Wsdl1SoapOperationImpl();
operation.setName(new QName(wsdlPortType.getQName().getNamespaceURI(), wsdlOperation.getName()));
if (wsdlSoapOperation != null) {
operation.setSoapAction(wsdlSoapOperation.getSoapActionURI());
operation.setStyle(getStyle(wsdlSoapOperation.getStyle()));
} else {
operation.setSoapAction("");
}
if (operation.getStyle() == null) {
operation.setStyle(binding.getStyle() != null ? binding.getStyle() : Style.DOCUMENT);
}
if (wsdlOperation.getStyle() == OperationType.ONE_WAY) {
operation.setMep(JbiConstants.IN_ONLY);
} else if (wsdlOperation.getStyle() == OperationType.REQUEST_RESPONSE) {
operation.setMep(JbiConstants.IN_OUT);
}
// Create input
createInput(operation, wsdlBindingOperation);
// Create output
createOutput(operation, wsdlBindingOperation);
// Create faults
Collection faults = wsdlOperation.getFaults().values();
for (Iterator itFault = faults.iterator(); itFault.hasNext();) {
Fault fault = (Fault) itFault.next();
createFault(operation, wsdlBindingOperation.getBindingFaults().get(fault.getName()));
}
// Add operation
binding.addOperation(operation);
}
return binding;
}