// setting the name
axisService.setName(wsdl4jService.getQName().getLocalPart());
// ///////////////// adding Policies ////////////////////////////
PolicyInclude policyInclude = new PolicyInclude();
List wsdlPolicies = getPoliciesAsExtElements(wsdlDefinition
.getExtensibilityElements());
Iterator wsdlPolicyIterator = wsdlPolicies.iterator();
while (wsdlPolicyIterator.hasNext()) {
Policy wsdlPolicy = (Policy) wsdlPolicyIterator.next();
if (wsdlPolicy.getPolicyURI() != null) {
policyInclude.registerPolicy(wsdlPolicy);
}
}
axisService.setPolicyInclude(policyInclude);
// ////////////////////////////////////////////////////////////////
// setting the schema
Types types = wsdlDefinition.getTypes();
if (types != null) {
Iterator extElements = types.getExtensibilityElements().iterator();
ExtensibilityElement extElement;
while (extElements.hasNext()) {
extElement = (ExtensibilityElement) extElements.next();
if (extElement instanceof Schema) {
Element schemaElement = ((Schema) extElement).getElement();
axisService.setSchema(getXMLSchema(schemaElement));
}
}
}
HashMap resolvedRPCWrapperElements = new HashMap();
XmlSchema xmlSchemaForWrappedElements = generateWrapperSchema(
wsdlDefinition, resolvedRPCWrapperElements);
if (xmlSchemaForWrappedElements != null) {
axisService.setSchema(xmlSchemaForWrappedElements);
}
// getting the port of the service with SOAP binding
Map ports = wsdl4jService.getPorts();
if (ports.isEmpty()) {
logger.error("atleast one port should be specified");
throw new WSDLProcessingException(
"atleast one Port should be specified");
}
Port wsdl4jPort = getPortWithSoapBinding(ports);
if (wsdl4jPort == null) {
logger
.error("atleast one port with a soap binding should be specified");
throw new WSDLProcessingException("no port with soap binding found");
}
Binding wsdl4jBinding = wsdl4jPort.getBinding();
PortType wsdl4jPortType = wsdl4jBinding.getPortType();
// ///////////// Adding policies //////////////////////////////////
List axisServicePolicies;
// wsdl:Service
axisServicePolicies = getPoliciesAsExtElements(wsdl4jService
.getExtensibilityElements());
addPolicyElements(PolicyInclude.SERVICE_POLICY, axisServicePolicies,
policyInclude);
// wsdl:Port
axisServicePolicies = getPoliciesAsExtElements(wsdl4jPort
.getExtensibilityElements());
addPolicyElements(PolicyInclude.PORT_POLICY, axisServicePolicies,
policyInclude);
// wsdl:PortType
axisServicePolicies = getPoliciesAsExtAttributes(wsdl4jPortType
.getExtensionAttributes());
addPolicyElements(PolicyInclude.PORT_TYPE_POLICY, axisServicePolicies,
policyInclude);
// wsdl:Binding
axisServicePolicies = getPoliciesAsExtElements(wsdl4jBinding
.getExtensibilityElements());
addPolicyElements(PolicyInclude.BINDING_POLICY, axisServicePolicies,
policyInclude);
// ////////////////////////////////////////////////////////////////
Iterator wsdl4jOperations = wsdl4jPortType.getOperations().iterator();
while (wsdl4jOperations.hasNext()) {
Operation wsdl4jOperation = (Operation) wsdl4jOperations.next();
BindingOperation wsdl4jBindingOperation = wsdl4jBinding
.getBindingOperation(wsdl4jOperation.getName(), null, null);
AxisOperation axisOperation;
try {
axisOperation = AxisOperationFactory
.getAxisOperation(getMessageExchangePattern(wsdl4jOperation));
// setting parent
axisOperation.setParent(axisService);
// setting operation name
axisOperation.setName(new QName(wsdl4jOperation.getName()));
// //////////////adding Policy //////////////////////////////
PolicyInclude operationPolicyInclude = new PolicyInclude(
axisService.getPolicyInclude());
List operationPolicies;
// wsdl:PortType -> wsdl:Operation
operationPolicies = getPoliciesAsExtElements(wsdl4jOperation
.getExtensibilityElements());
addPolicyElements(PolicyInclude.OPERATION_POLICY,
operationPolicies, operationPolicyInclude);
// wsdl:Binding -> wsdl:Operation
operationPolicies = getPoliciesAsExtElements(wsdl4jBindingOperation
.getExtensibilityElements());
addPolicyElements(PolicyInclude.BINDING_OPERATION_POLICY,
operationPolicies, operationPolicyInclude);
axisOperation.setPolicyInclude(operationPolicyInclude);
// /////////////////////////////////////////////////////////////
String soapActionURI = getSOAPActionURI(wsdl4jBindingOperation
.getExtensibilityElements());
if (soapActionURI != null) {
axisService.mapActionToOperation(soapActionURI,
axisOperation);
}
// Input
Input wsdl4jInput = wsdl4jOperation.getInput();
BindingInput wsdl4jBindingInput = wsdl4jBindingOperation
.getBindingInput();
Message wsdl4jInputMessage = wsdl4jInput.getMessage();
AxisMessage axisInputMessage = axisOperation
.getMessage(WSDLConstants.MESSAGE_LABEL_IN_VALUE);
// ////////////////// adding Policies /////////////////////////
PolicyInclude inputPolicyInclue = new PolicyInclude(
axisOperation.getPolicyInclude());
List inputMessagePolicies;
// wsdl:PortType -> wsdl:Operation -> wsdl:Input
inputMessagePolicies = getPoliciesAsExtAttributes(wsdl4jInput
.getExtensionAttributes());
addPolicyElements(PolicyInclude.INPUT_POLICY,
inputMessagePolicies, inputPolicyInclue);
// wsdl:Binding -> wsdl:Operation -> wsdl:Input
inputMessagePolicies = getPoliciesAsExtElements(wsdl4jBindingInput
.getExtensibilityElements());
addPolicyElements(PolicyInclude.BINDING_INPUT_POLICY,
inputMessagePolicies, inputPolicyInclue);
// wsdl:Message
inputMessagePolicies = getPoliciesAsExtElements(wsdl4jInputMessage
.getExtensibilityElements());
addPolicyElements(PolicyInclude.MESSAGE_POLICY,
inputMessagePolicies, inputPolicyInclue);
axisInputMessage.setPolicyInclude(policyInclude);
// /////////////////////////////////////////////////////////////
// setting the element qname
axisInputMessage.setElementQName(generateReferenceQname(
new QName(wsdl4jPortType.getQName().getNamespaceURI(),
wsdl4jOperation.getName()), wsdl4jInputMessage,
findWrapppable(wsdl4jInputMessage),
resolvedRPCWrapperElements));
// setting wsa:Action
String wsaActionForInput = getWsaAction(wsdl4jInput
.getExtensionAttributes());
if (wsaActionForInput != null
&& wsaActionForInput.length() != 0) {
axisService.mapActionToOperation(wsaActionForInput,
axisOperation);
}
Output wsdl4jOutput = wsdl4jOperation.getOutput();
BindingOutput wsdl4jBindingOutput = wsdl4jBindingOperation
.getBindingOutput();
if (wsdl4jOutput != null) {
AxisMessage axisOutputMessage = axisOperation
.getMessage(WSDLConstants.MESSAGE_LABEL_OUT_VALUE);
Message wsdl4jOutputMessage = wsdl4jOutput.getMessage();
// ///////////// adding Policies ///////////////////////////
PolicyInclude outputPolicyInclude = new PolicyInclude(
axisService.getPolicyInclude());
List outputPolicies;
// wsdl:Output
outputPolicies = getPoliciesAsExtAttributes(wsdl4jOutput