You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-dev@axis.apache.org by aj...@apache.org on 2005/06/29 06:14:16 UTC
svn commit: r202314 - in
/webservices/axis/trunk/java/modules/wsdl/src/org/apache/axis/wsdl:
builder/wsdl4j/ codegen/emitter/ template/java/
Author: ajith
Date: Tue Jun 28 21:14:13 2005
New Revision: 202314
URL: http://svn.apache.org/viewcvs?rev=202314&view=rev
Log:
Adding the databinding support. Note that this support is not complete yet
Modified:
webservices/axis/trunk/java/modules/wsdl/src/org/apache/axis/wsdl/builder/wsdl4j/WSDLPump.java
webservices/axis/trunk/java/modules/wsdl/src/org/apache/axis/wsdl/codegen/emitter/MultiLanguageClientEmitter.java
webservices/axis/trunk/java/modules/wsdl/src/org/apache/axis/wsdl/template/java/InterfaceImplementationTemplate.xsl
webservices/axis/trunk/java/modules/wsdl/src/org/apache/axis/wsdl/template/java/XMLBeansSupporterTemplate.xsl
Modified: webservices/axis/trunk/java/modules/wsdl/src/org/apache/axis/wsdl/builder/wsdl4j/WSDLPump.java
URL: http://svn.apache.org/viewcvs/webservices/axis/trunk/java/modules/wsdl/src/org/apache/axis/wsdl/builder/wsdl4j/WSDLPump.java?rev=202314&r1=202313&r2=202314&view=diff
==============================================================================
--- webservices/axis/trunk/java/modules/wsdl/src/org/apache/axis/wsdl/builder/wsdl4j/WSDLPump.java (original)
+++ webservices/axis/trunk/java/modules/wsdl/src/org/apache/axis/wsdl/builder/wsdl4j/WSDLPump.java Tue Jun 28 21:14:13 2005
@@ -1,18 +1,18 @@
/*
- * Copyright 2001-2004 The Apache Software Foundation.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
+* Copyright 2001-2004 The Apache Software Foundation.
+*
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
package org.apache.axis.wsdl.builder.wsdl4j;
import java.util.Iterator;
@@ -77,593 +77,593 @@
*/
public class WSDLPump {
- private static final String BOUND_INTERFACE_NAME = "BoundInterface";
+ private static final String BOUND_INTERFACE_NAME = "BoundInterface";
+
+ private WSDLDescription womDefinition;
+
+ private Definition wsdl4jParsedDefinition;
- private WSDLDescription womDefinition;
+ private WSDLComponentFactory wsdlComponenetFactory;
- private Definition wsdl4jParsedDefinition;
- private WSDLComponentFactory wsdlComponenetFactory;
-
-
- private List resolvedMultipartMessageList = new LinkedList();
-
- public WSDLPump(WSDLDescription womDefinition,
- Definition wsdl4jParsedDefinition) {
- this(womDefinition, wsdl4jParsedDefinition, womDefinition);
- }
-
- public WSDLPump(WSDLDescription womDefinition,
- Definition wsdl4jParsedDefinition,
- WSDLComponentFactory wsdlComponentFactory) {
- this.womDefinition = womDefinition;
- this.wsdl4jParsedDefinition = wsdl4jParsedDefinition;
- this.wsdlComponenetFactory = wsdlComponentFactory;
- }
-
- public void pump() {
- if (null != this.wsdl4jParsedDefinition && null != this.womDefinition) {
- this.populateDefinition(this.womDefinition,
- this.wsdl4jParsedDefinition);
- } else {
- throw new WSDLProcessingException("Properties not set properly");
- }
-
- }
-
- private void populateDefinition(WSDLDescription wsdlDefinition,
- Definition wsdl4JDefinition) {
- //Go through the WSDL4J Definition and pump it to the WOM
- wsdlDefinition.setWSDL1DefinitionName(wsdl4JDefinition.getQName());
- wsdlDefinition
- .setTargetNameSpace(wsdl4JDefinition.getTargetNamespace());
- wsdlDefinition.setNamespaces(wsdl4JDefinition.getNamespaces());
- this.copyExtensibleElements(wsdl4JDefinition.getExtensibilityElements(), wsdlDefinition);
-
- /////////////////////////////////////////////////////////////////////
- // Order of the following items shouldn't be changed unless you //
- // really know what you are doing. Reason being the components that //
- // are copied(pumped) towards the end depend on the components that //
- // has already being pumped. Following Lists some of the //
- // dependencies. //
- //1) The Binding refers to the Interface //
- //2) The Endpoint refers to the Bindings //
- // .... //
- // //
- //////////////////////////////////////////////////////////////////////
-
- //////////////////(1)First Copy the Types/////////////////////////////
- //Types may get changed inside the Operation pumping.
-
- Types wsdl4jTypes = wsdl4JDefinition.getTypes();
- if (null != wsdl4jTypes) {
- WSDLTypes wsdlTypes = this.wsdlComponenetFactory.createTypes();
-
-
- this.copyExtensibleElements(wsdl4jTypes.getExtensibilityElements(),
- wsdlTypes);
-
- this.womDefinition.setTypes(wsdlTypes);
- }
-
- ///////////////////(2)Copy the Interfaces///////////////////////////
- //copy the Interfaces: Get the PortTypes from WSDL4J parse OM and
- // copy it to the
- //WOM's WSDLInterface Components
-
- Iterator portTypeIterator = wsdl4JDefinition.getPortTypes().values()
- .iterator();
- WSDLInterface wsdlInterface;
- PortType portType;
- while (portTypeIterator.hasNext()) {
- wsdlInterface = this.wsdlComponenetFactory.createInterface();
- portType = (PortType) portTypeIterator.next();
- this.populateInterfaces(wsdlInterface, portType);
- this.copyExtensibilityAttribute(portType.getExtensionAttributes(),
- wsdlInterface);
- wsdlDefinition.addInterface(wsdlInterface);
- }
-
- //////////////////(3)Copy the Bindings///////////////////////
- //pump the Bindings: Get the Bindings map from WSDL4J and create a new
- // map of
- //WSDLBinding elements
-
- Iterator bindingIterator = wsdl4JDefinition.getBindings().values()
- .iterator();
- WSDLBinding wsdlBinding;
- Binding wsdl4jBinding;
- while (bindingIterator.hasNext()) {
- wsdlBinding = this.wsdlComponenetFactory.createBinding();
- wsdl4jBinding = (Binding) bindingIterator.next();
- this.populateBindings(wsdlBinding, wsdl4jBinding);
- this.copyExtensibleElements(wsdl4jBinding.getExtensibilityElements(),
- wsdlBinding);
- wsdlDefinition.addBinding(wsdlBinding);
-
- }
-
- ///////////////////(4)Copy the Services///////////////////////////////
-
- Iterator serviceIterator = wsdl4JDefinition.getServices().values()
- .iterator();
- WSDLService wsdlService;
- Service wsdl4jService;
- while (serviceIterator.hasNext()) {
- wsdlService = this.wsdlComponenetFactory.createService();
- wsdl4jService = (Service) serviceIterator.next();
- this.populateServices(wsdlService, wsdl4jService);
- this.copyExtensibleElements(wsdl4jService.getExtensibilityElements(),
- wsdlService);
- wsdlDefinition.addService(wsdlService);
- }
-
- }
-
- //////////////////////////////////////////////////////////////////////////////
- ////////////////////////// Top level Components Copying
- // ////////////////////
-
- /**
- * Simply Copy information.
- *
- * @param wsdlInterface
- * @param wsdl4jPortType
- */
- //FIXME Evaluate a way of injecting features and priperties with a general
- // formatted input
- private void populateInterfaces(WSDLInterface wsdlInterface,
- PortType wsdl4jPortType) {
-
- //Copy the Attrebute information items
- //Copied with the Same QName so it will require no Query in Binding
- //Coping.
- wsdlInterface.setName(wsdl4jPortType.getQName());
- Iterator wsdl4JOperationsIterator =
- wsdl4jPortType.getOperations().iterator();
- WSDLOperation wsdloperation;
- Operation wsdl4jOperation;
- while (wsdl4JOperationsIterator.hasNext()) {
- wsdloperation = this.wsdlComponenetFactory.createOperation();
- wsdl4jOperation = (Operation) wsdl4JOperationsIterator.next();
- this.populateOperations(wsdloperation,
- wsdl4jOperation,
- wsdl4jPortType.getQName().getNamespaceURI());
- this.copyExtensibleElements(wsdl4jOperation.getExtensibilityElements(), wsdloperation);
- wsdlInterface.setOperation(wsdloperation);
- }
- }
-
- /**
- * Pre Condition: The Interface Components must be copied by now.
- */
- private void populateBindings(WSDLBinding wsdlBinding, Binding wsdl4JBinding) {
- //Copy attrebutes
- wsdlBinding.setName(wsdl4JBinding.getQName());
- QName interfaceName = wsdl4JBinding.getPortType().getQName();
- WSDLInterface wsdlInterface =
- this.womDefinition.getInterface(interfaceName);
-
- //FIXME Do We need this eventually???
- if (null == wsdlInterface)
- throw new WSDLProcessingException(
- "Interface/PortType not found for the Binding :"
- + wsdlBinding.getName());
- wsdlBinding.setBoundInterface(wsdlInterface);
- Iterator bindingoperationsIterator =
- wsdl4JBinding.getBindingOperations().iterator();
- WSDLBindingOperation wsdlBindingOperation;
- BindingOperation wsdl4jBindingOperation;
- while (bindingoperationsIterator.hasNext()) {
- wsdlBindingOperation =
- this.wsdlComponenetFactory.createWSDLBindingOperation();
- wsdl4jBindingOperation =
- (BindingOperation)bindingoperationsIterator.next();
- this.populateBindingOperation(wsdlBindingOperation,
- wsdl4jBindingOperation,
- wsdl4JBinding.getQName().getNamespaceURI());
- wsdlBindingOperation.setOperation(
- wsdlInterface.getOperation(wsdl4jBindingOperation.getOperation().getName())
- );
- this.copyExtensibleElements(
- wsdl4jBindingOperation.getExtensibilityElements(),
- wsdlBindingOperation);
- wsdlBinding.addBindingOperation(wsdlBindingOperation);
- }
-
- }
-
- public void populateServices(WSDLService wsdlService, Service wsdl4jService) {
- wsdlService.setName(wsdl4jService.getQName());
- Iterator wsdl4jportsIterator =
- wsdl4jService.getPorts().values().iterator();
- wsdlService.setServiceInterface(this.getBoundInterface(wsdlService));
- WSDLEndpoint wsdlEndpoint;
- Port wsdl4jPort;
- while (wsdl4jportsIterator.hasNext()) {
- wsdlEndpoint = this.wsdlComponenetFactory.createEndpoint();
- wsdl4jPort = (Port) wsdl4jportsIterator.next();
- this.populatePorts(wsdlEndpoint,
- wsdl4jPort,
- wsdl4jService.getQName().getNamespaceURI());
- this.copyExtensibleElements(wsdl4jPort.getExtensibilityElements(),
- wsdlEndpoint);
- wsdlService.setEndpoint(wsdlEndpoint);
- }
-
- }
-
- /////////////////////////////////////////////////////////////////////////////
- //////////////////////////// Internal Component Copying ///////////////////
- //TODO Faults
- public void populateOperations(WSDLOperation wsdlOperation,
- Operation wsdl4jOperation, String nameSpaceOfTheOperation) {
- //Copy Name Attrebute
- wsdlOperation.setName(new QName(nameSpaceOfTheOperation,
- wsdl4jOperation.getName()));
-
- //This code make no attempt to make use of the special xs:Token
- //defined in the WSDL 2.0. eg like #any, #none
- // Create the Input Message and add
- Input wsdl4jInputMessage = wsdl4jOperation.getInput();
-
- if(null != wsdl4jInputMessage){
- MessageReference wsdlInputMessage = this.wsdlComponenetFactory
- .createMessageReference();
- wsdlInputMessage.setDirection(WSDLConstants.WSDL_MESSAGE_DIRECTION_IN);
- wsdlInputMessage.setMessageLabel(WSDLConstants.MESSAGE_LABEL_IN_VALUE);
- wsdlInputMessage.setElement(this.generateReferenceQname(wsdl4jInputMessage.getMessage()));
- this.copyExtensibleElements(
- (wsdl4jInputMessage.getMessage()).getExtensibilityElements(),
- wsdlInputMessage
- );
- this.copyExtensibilityAttribute(wsdl4jInputMessage.getExtensionAttributes(),
- wsdlInputMessage);
- wsdlOperation.setInputMessage(wsdlInputMessage);
- }
-
- //Create an output message and add
- Output wsdl4jOutputMessage = wsdl4jOperation.getOutput();
- if(null != wsdl4jOutputMessage){
- MessageReference wsdlOutputMessage =
- this.wsdlComponenetFactory.createMessageReference();
- wsdlOutputMessage.setDirection(WSDLConstants.WSDL_MESSAGE_DIRECTION_OUT);
- wsdlOutputMessage.setMessageLabel(WSDLConstants.MESSAGE_LABEL_OUT_VALUE);
-
- wsdlOutputMessage.setElement(this.generateReferenceQname(wsdl4jOutputMessage.getMessage()));
- this.copyExtensibleElements(
- (wsdl4jOutputMessage.getMessage()).getExtensibilityElements(),
- wsdlOutputMessage
- );
- this.copyExtensibilityAttribute(wsdl4jOutputMessage.getExtensionAttributes(),
- wsdlOutputMessage);
- wsdlOperation.setOutputMessage(wsdlOutputMessage);
- }
-
- Map faults = wsdl4jOperation.getFaults();
- Iterator faultKeyIterator = faults.keySet().iterator();
- WSDLFaultReference faultReference = null;
-
- while(faultKeyIterator.hasNext()){
-
- Fault fault = (Fault)faults.get(faultKeyIterator.next());
- faultReference = wsdlComponenetFactory.createFaultReference();
- faultReference.setDirection(WSDLConstants.WSDL_MESSAGE_DIRECTION_OUT);
- faultReference.setRef(this.generateReferenceQname(fault.getMessage()));
- wsdlOperation.addOutFault(faultReference);
- this.copyExtensibilityAttribute(fault.getExtensionAttributes(), faultReference);
- //TODO Fault Message lable
-
- }
-
- //Set the MEP
- wsdlOperation.setMessageExchangePattern(WSDL11MEPFinder
- .getMEP(wsdl4jOperation));
-
- }
- private QName generateReferenceQname(Message wsdl4jMessage){
- QName referenceQName = null;
- if (wsdl4jMessage.getParts().size() > 1){
- // Multipart Message
-
- // Check whether this message parts have been made to a type
- Iterator multipartListIterator = this.resolvedMultipartMessageList.iterator();
- boolean multipartAlreadyResolved = false;
- while(multipartListIterator.hasNext() && !multipartAlreadyResolved){
- QName temp = (QName)multipartListIterator.next();
- multipartAlreadyResolved = wsdl4jMessage.getQName().equals(temp);
- }
- if(multipartAlreadyResolved){
- //This message with multiple parts has resolved and a new type has been
- //made out of it earlier.
- //FIXME Actual element name should it be xs:, if yes change the qname added to the
- //resolvedmessage list too.
- referenceQName = wsdl4jMessage.getQName();
- }else{
- //Get the list of multiparts of the message and create a new Element
- //out of it and add it to the schema.
- Map parts = wsdl4jMessage.getParts();
- Element element = null;
- WSDLTypes types = womDefinition.getTypes();
- if(null == types){
- XmlDocument newDoc = new XmlDocument();
-
- Element schemaElement = newDoc.createElement("schema");//http://www.w3.org/2001/XMLSchema
- types =wsdlComponenetFactory.createTypes();
- ExtensionFactory extensionFactory = wsdlComponenetFactory.createExtensionFactory();
- org.apache.wsdl.extensions.Schema typesElement = (org.apache.wsdl.extensions.Schema)extensionFactory.getExtensionElement(ExtensionConstants.SCHEMA);
- typesElement.setElelment(schemaElement);
- types.addExtensibilityElement(typesElement);
- this.womDefinition.setTypes(types);
- }
- Iterator schemaEIIterator = types.getExtensibilityElements().iterator();
- while(schemaEIIterator.hasNext()){
- WSDLExtensibilityElement temp = (WSDLExtensibilityElement)schemaEIIterator.next();
- if(ExtensionConstants.SCHEMA.equals(temp.getType())){
- element = ((org.apache.wsdl.extensions.Schema)temp).getElelment();
- break;
- }
- }
-
- Document doc = element.getOwnerDocument();
- String name = wsdl4jMessage.getQName().getLocalPart();
- Element newElement = doc.createElement("complexType");
- newElement.setAttribute("name", name);
-
- Element cmplxContent = doc.createElement("complexContent");
- Element child;
- Iterator iterator = parts.keySet().iterator();
- while(iterator.hasNext()){
- Part part = (Part)parts.get(iterator.next());
- QName elementName = part.getElementName();
- if(null == elementName){
- elementName = part.getTypeName();
- }
-
-
- child = doc.createElement("element");
- child.setAttribute("name", "var"+elementName.getLocalPart());
- child.setAttribute("type", elementName.getNamespaceURI()+":"+elementName.getLocalPart());
- cmplxContent.appendChild(child);
- }
-
-
- newElement.appendChild(cmplxContent);
-
- element.appendChild(newElement);
- //Now since a new type is created augmenting the parts add the QName
- //of the newly created type as the messageReference's name.
- referenceQName = wsdl4jMessage.getQName();
- //Add this message as a resolved message, so that incase some other
- //operation refer to the same message the if above will take a hit
- //and the cashed QName can be used instead of crating another type
- //for the same message.
-
- this.resolvedMultipartMessageList.add(wsdl4jMessage.getQName());
-
- }
- }else{
- //Only one part so copy the QName of the referenced type.
- Iterator outputIterator =
- wsdl4jMessage.getParts().values().iterator();
- if (outputIterator.hasNext()) {
- Part outPart = ((Part) outputIterator.next());
- QName typeName;
- if (null != (typeName = outPart.getTypeName())) {
- referenceQName = typeName;
- } else {
- referenceQName = outPart.getElementName();
- }
- }
- }
- return referenceQName;
- }
-
- private void populateBindingOperation(
- WSDLBindingOperation wsdlBindingOperation,
- BindingOperation wsdl4jBindingOperation,
- String nameSpaceOfTheBindingOperation) {
-
- wsdlBindingOperation.setName(new QName(nameSpaceOfTheBindingOperation,
- wsdl4jBindingOperation.getName()));
- BindingInput wsdl4jInputBinding =
- wsdl4jBindingOperation.getBindingInput();
- if(null != wsdl4jInputBinding){
- WSDLBindingMessageReference wsdlInputBinding =
- this.wsdlComponenetFactory.createWSDLBindingMessageReference();
- wsdlInputBinding.setDirection(WSDLConstants.WSDL_MESSAGE_DIRECTION_IN);
- //TODO Faults
- this.copyExtensibleElements(wsdl4jInputBinding.getExtensibilityElements(),
- wsdlInputBinding);
- wsdlBindingOperation.setInput(wsdlInputBinding);
- }
-
- BindingOutput wsdl4jOutputBinding = wsdl4jBindingOperation
- .getBindingOutput();
- if(null != wsdl4jOutputBinding){
- WSDLBindingMessageReference wsdlOutputBinding = this.wsdlComponenetFactory
- .createWSDLBindingMessageReference();
-
- wsdlOutputBinding.setDirection(WSDLConstants.WSDL_MESSAGE_DIRECTION_OUT);
- //TODO Faults
- this.copyExtensibleElements(wsdl4jOutputBinding.getExtensibilityElements(),
- wsdlOutputBinding);
- wsdlBindingOperation.setOutput(wsdlOutputBinding);
- }
-
-
- Map bindingFaults = wsdl4jBindingOperation.getBindingFaults();
- Iterator keyIterator = bindingFaults.keySet().iterator();
- while(keyIterator.hasNext()){
- BindingFault bindingFault = (BindingFault)bindingFaults.get(keyIterator.next());
- WSDLBindingFault womBindingFault = this.wsdlComponenetFactory.createBindingFault();
- this.copyExtensibleElements(bindingFault.getExtensibilityElements(), womBindingFault);
- wsdlBindingOperation.addOutFault(womBindingFault);
- }
-
- }
-
- public void populatePorts(WSDLEndpoint wsdlEndpoint, Port wsdl4jPort,
- String targetNamspace) {
- wsdlEndpoint.setName(new QName(targetNamspace, wsdl4jPort.getName()));
-
- wsdlEndpoint.setBinding(this.womDefinition.getBinding(wsdl4jPort
- .getBinding().getQName()));
-
- }
-
- /**
- * This method will fill up the gap of WSDL 1.1 and WSDL 2.0 w.r.t. the
- * bound interface for the Service Component Defined in the WSDL 2.0. Logic
- * being if there exist only one PortType in the WSDL 1.1 file then that
- * will be set as the bound interface of the Service. If more than one
- * Porttype exist in the WSDl 1.1 file this will create a dummy Interface
- * with the available PortTypes and will return that interface so that it
- * will inherit all those interfaces.
- *
- * Eventuall this will have to be fixed using user input since
- *
- * @param service
- * @return
- */
- private WSDLInterface getBoundInterface(WSDLService service) {
-
- // Throw an exception if there are no interfaces defined as at yet.
- if (0 == this.womDefinition.getWsdlInterfaces().size())
- throw new WSDLProcessingException(
- "There are no "
- + "Interfaces/PortTypes identified in the current partially built"
- + "WOM");
-
- //If there is only one Interface available hten return that because
- // normally
- // that interface must be the one to the service should get bound.
- if (1 == this.womDefinition.getWsdlInterfaces().size())
- return (WSDLInterface) this.womDefinition.getWsdlInterfaces()
- .values().iterator().next();
-
- //If there are more than one interface available... For the time being
- // create a
- // new interface and set all those existing interfaces as
- // superinterfaces of it
- // and return.
- WSDLInterface newBoundInterface = this.womDefinition.createInterface();
- newBoundInterface.setName(new QName(service.getNamespace(), service
- .getName().getLocalPart()
- + BOUND_INTERFACE_NAME));
- Iterator interfaceIterator = this.womDefinition.getWsdlInterfaces()
- .values().iterator();
- while (interfaceIterator.hasNext()) {
- newBoundInterface
- .addSuperInterface((WSDLInterface) interfaceIterator.next());
- }
- return newBoundInterface;
- }
-
- /**
- * Get the Extensible elements form wsdl4jExtensibleElements
- * <code>Vector</code> if any and copy them to <code>Component</code>
- *
- * @param wsdl4jExtensibleElements
- * @param womExtensibleElements
- */
- private void copyExtensibleElements(List wsdl4jExtensibleElements,
- Component component) {
- Iterator iterator = wsdl4jExtensibleElements.iterator();
- ExtensionFactory extensionFactory = this.wsdlComponenetFactory
- .createExtensionFactory();
- while (iterator.hasNext()) {
-
- ExtensibilityElement wsdl4jElement = (ExtensibilityElement) iterator
- .next();
-
- if (wsdl4jElement instanceof UnknownExtensibilityElement) {
- UnknownExtensibilityElement unknown = (UnknownExtensibilityElement) (wsdl4jElement);
- DefaultExtensibilityElement extensibilityElement = (DefaultExtensibilityElement) extensionFactory
- .getExtensionElement(wsdl4jElement.getElementType());
- extensibilityElement.setElement(unknown.getElement());
- Boolean required = unknown.getRequired();
- if (null != required) {
- extensibilityElement.setRequired(required.booleanValue());
- }
- component.addExtensibilityElement(extensibilityElement);
- } else if (wsdl4jElement instanceof SOAPAddress) {
- SOAPAddress soapAddress = (SOAPAddress) wsdl4jElement;
- org.apache.wsdl.extensions.SOAPAddress extensibilityElement = (org.apache.wsdl.extensions.SOAPAddress) extensionFactory
- .getExtensionElement(soapAddress.getElementType());
- extensibilityElement.setLocationURI(soapAddress
- .getLocationURI());
- Boolean required = soapAddress.getRequired();
- if (null != required) {
- extensibilityElement.setRequired(required.booleanValue());
- }
- component.addExtensibilityElement(extensibilityElement);
- }else if(wsdl4jElement instanceof Schema) {
- Schema schema = (Schema)wsdl4jElement;
- org.apache.wsdl.extensions.Schema extensibilityElement = (org.apache.wsdl.extensions.Schema)extensionFactory.getExtensionElement(schema.getElementType());
- extensibilityElement.setElelment(schema.getElement());
- Boolean required = schema.getRequired();
- if(null != required){
- extensibilityElement.setRequired(required.booleanValue());
- }
- component.addExtensibilityElement(extensibilityElement);
- }else if(SOAPConstants.Q_ELEM_SOAP_OPERATION.equals(wsdl4jElement.getElementType())){
- SOAPOperation soapOperation = (SOAPOperation)wsdl4jElement;
- org.apache.wsdl.extensions.SOAPOperation extensibilityElement = (org.apache.wsdl.extensions.SOAPOperation)extensionFactory.getExtensionElement(soapOperation.getElementType());
- extensibilityElement.setSoapAction(soapOperation.getSoapActionURI());
- extensibilityElement.setStyle(soapOperation.getStyle());
- Boolean required = soapOperation.getRequired();
- if(null != required){
- extensibilityElement.setRequired(required.booleanValue());
- }
- component.addExtensibilityElement(extensibilityElement);
- }else if(SOAPConstants.Q_ELEM_SOAP_BODY.equals(wsdl4jElement.getElementType())){
- SOAPBody soapBody = (SOAPBody)wsdl4jElement;
- org.apache.wsdl.extensions.SOAPBody extensibilityElement = (org.apache.wsdl.extensions.SOAPBody)extensionFactory.getExtensionElement(soapBody.getElementType());
- extensibilityElement.setNamespaceURI(soapBody.getNamespaceURI());
- extensibilityElement.setUse(soapBody.getUse());
- Boolean required = soapBody.getRequired();
- if(null != required){
- extensibilityElement.setRequired(required.booleanValue());
- }
- component.addExtensibilityElement(extensibilityElement);
- }else if(SOAPConstants.Q_ELEM_SOAP_BINDING.equals(wsdl4jElement.getElementType())){
- SOAPBinding soapBinding = (SOAPBinding)wsdl4jElement;
- org.apache.wsdl.extensions.SOAPBinding extensibilityElement = (org.apache.wsdl.extensions.SOAPBinding)extensionFactory.getExtensionElement(soapBinding.getElementType());
- extensibilityElement.setTransportURI(soapBinding.getTransportURI());
- extensibilityElement.setStyle(soapBinding.getStyle());
- Boolean required = soapBinding.getRequired();
- if(null != required){
- extensibilityElement.setRequired(required.booleanValue());
- }
- component.addExtensibilityElement(extensibilityElement);
- }else {
+ private List resolvedMultipartMessageList = new LinkedList();
+
+ public WSDLPump(WSDLDescription womDefinition,
+ Definition wsdl4jParsedDefinition) {
+ this(womDefinition, wsdl4jParsedDefinition, womDefinition);
+ }
+
+ public WSDLPump(WSDLDescription womDefinition,
+ Definition wsdl4jParsedDefinition,
+ WSDLComponentFactory wsdlComponentFactory) {
+ this.womDefinition = womDefinition;
+ this.wsdl4jParsedDefinition = wsdl4jParsedDefinition;
+ this.wsdlComponenetFactory = wsdlComponentFactory;
+ }
+
+ public void pump() {
+ if (null != this.wsdl4jParsedDefinition && null != this.womDefinition) {
+ this.populateDefinition(this.womDefinition,
+ this.wsdl4jParsedDefinition);
+ } else {
+ throw new WSDLProcessingException("Properties not set properly");
+ }
+
+ }
+
+ private void populateDefinition(WSDLDescription wsdlDefinition,
+ Definition wsdl4JDefinition) {
+ //Go through the WSDL4J Definition and pump it to the WOM
+ wsdlDefinition.setWSDL1DefinitionName(wsdl4JDefinition.getQName());
+ wsdlDefinition
+ .setTargetNameSpace(wsdl4JDefinition.getTargetNamespace());
+ wsdlDefinition.setNamespaces(wsdl4JDefinition.getNamespaces());
+ this.copyExtensibleElements(wsdl4JDefinition.getExtensibilityElements(), wsdlDefinition);
+
+ /////////////////////////////////////////////////////////////////////
+ // Order of the following items shouldn't be changed unless you //
+ // really know what you are doing. Reason being the components that //
+ // are copied(pumped) towards the end depend on the components that //
+ // has already being pumped. Following Lists some of the //
+ // dependencies. //
+ //1) The Binding refers to the Interface //
+ //2) The Endpoint refers to the Bindings //
+ // .... //
+ // //
+ //////////////////////////////////////////////////////////////////////
+
+ //////////////////(1)First Copy the Types/////////////////////////////
+ //Types may get changed inside the Operation pumping.
+
+ Types wsdl4jTypes = wsdl4JDefinition.getTypes();
+ if (null != wsdl4jTypes) {
+ WSDLTypes wsdlTypes = this.wsdlComponenetFactory.createTypes();
+
+
+ this.copyExtensibleElements(wsdl4jTypes.getExtensibilityElements(),
+ wsdlTypes);
+
+ this.womDefinition.setTypes(wsdlTypes);
+ }
+
+ ///////////////////(2)Copy the Interfaces///////////////////////////
+ //copy the Interfaces: Get the PortTypes from WSDL4J parse OM and
+ // copy it to the
+ //WOM's WSDLInterface Components
+
+ Iterator portTypeIterator = wsdl4JDefinition.getPortTypes().values()
+ .iterator();
+ WSDLInterface wsdlInterface;
+ PortType portType;
+ while (portTypeIterator.hasNext()) {
+ wsdlInterface = this.wsdlComponenetFactory.createInterface();
+ portType = (PortType) portTypeIterator.next();
+ this.populateInterfaces(wsdlInterface, portType);
+ this.copyExtensibilityAttribute(portType.getExtensionAttributes(),
+ wsdlInterface);
+ wsdlDefinition.addInterface(wsdlInterface);
+ }
+
+ //////////////////(3)Copy the Bindings///////////////////////
+ //pump the Bindings: Get the Bindings map from WSDL4J and create a new
+ // map of
+ //WSDLBinding elements
+
+ Iterator bindingIterator = wsdl4JDefinition.getBindings().values()
+ .iterator();
+ WSDLBinding wsdlBinding;
+ Binding wsdl4jBinding;
+ while (bindingIterator.hasNext()) {
+ wsdlBinding = this.wsdlComponenetFactory.createBinding();
+ wsdl4jBinding = (Binding) bindingIterator.next();
+ this.populateBindings(wsdlBinding, wsdl4jBinding);
+ this.copyExtensibleElements(wsdl4jBinding.getExtensibilityElements(),
+ wsdlBinding);
+ wsdlDefinition.addBinding(wsdlBinding);
+
+ }
+
+ ///////////////////(4)Copy the Services///////////////////////////////
+
+ Iterator serviceIterator = wsdl4JDefinition.getServices().values()
+ .iterator();
+ WSDLService wsdlService;
+ Service wsdl4jService;
+ while (serviceIterator.hasNext()) {
+ wsdlService = this.wsdlComponenetFactory.createService();
+ wsdl4jService = (Service) serviceIterator.next();
+ this.populateServices(wsdlService, wsdl4jService);
+ this.copyExtensibleElements(wsdl4jService.getExtensibilityElements(),
+ wsdlService);
+ wsdlDefinition.addService(wsdlService);
+ }
+
+ }
+
+ //////////////////////////////////////////////////////////////////////////////
+ ////////////////////////// Top level Components Copying
+ // ////////////////////
+
+ /**
+ * Simply Copy information.
+ *
+ * @param wsdlInterface
+ * @param wsdl4jPortType
+ */
+ //FIXME Evaluate a way of injecting features and priperties with a general
+ // formatted input
+ private void populateInterfaces(WSDLInterface wsdlInterface,
+ PortType wsdl4jPortType) {
+
+ //Copy the Attrebute information items
+ //Copied with the Same QName so it will require no Query in Binding
+ //Coping.
+ wsdlInterface.setName(wsdl4jPortType.getQName());
+ Iterator wsdl4JOperationsIterator =
+ wsdl4jPortType.getOperations().iterator();
+ WSDLOperation wsdloperation;
+ Operation wsdl4jOperation;
+ while (wsdl4JOperationsIterator.hasNext()) {
+ wsdloperation = this.wsdlComponenetFactory.createOperation();
+ wsdl4jOperation = (Operation) wsdl4JOperationsIterator.next();
+ this.populateOperations(wsdloperation,
+ wsdl4jOperation,
+ wsdl4jPortType.getQName().getNamespaceURI());
+ this.copyExtensibleElements(wsdl4jOperation.getExtensibilityElements(), wsdloperation);
+ wsdlInterface.setOperation(wsdloperation);
+ }
+ }
+
+ /**
+ * Pre Condition: The Interface Components must be copied by now.
+ */
+ private void populateBindings(WSDLBinding wsdlBinding, Binding wsdl4JBinding) {
+ //Copy attrebutes
+ wsdlBinding.setName(wsdl4JBinding.getQName());
+ QName interfaceName = wsdl4JBinding.getPortType().getQName();
+ WSDLInterface wsdlInterface =
+ this.womDefinition.getInterface(interfaceName);
+
+ //FIXME Do We need this eventually???
+ if (null == wsdlInterface)
+ throw new WSDLProcessingException(
+ "Interface/PortType not found for the Binding :"
+ + wsdlBinding.getName());
+ wsdlBinding.setBoundInterface(wsdlInterface);
+ Iterator bindingoperationsIterator =
+ wsdl4JBinding.getBindingOperations().iterator();
+ WSDLBindingOperation wsdlBindingOperation;
+ BindingOperation wsdl4jBindingOperation;
+ while (bindingoperationsIterator.hasNext()) {
+ wsdlBindingOperation =
+ this.wsdlComponenetFactory.createWSDLBindingOperation();
+ wsdl4jBindingOperation =
+ (BindingOperation)bindingoperationsIterator.next();
+ this.populateBindingOperation(wsdlBindingOperation,
+ wsdl4jBindingOperation,
+ wsdl4JBinding.getQName().getNamespaceURI());
+ wsdlBindingOperation.setOperation(
+ wsdlInterface.getOperation(wsdl4jBindingOperation.getOperation().getName())
+ );
+ this.copyExtensibleElements(
+ wsdl4jBindingOperation.getExtensibilityElements(),
+ wsdlBindingOperation);
+ wsdlBinding.addBindingOperation(wsdlBindingOperation);
+ }
+
+ }
+
+ public void populateServices(WSDLService wsdlService, Service wsdl4jService) {
+ wsdlService.setName(wsdl4jService.getQName());
+ Iterator wsdl4jportsIterator =
+ wsdl4jService.getPorts().values().iterator();
+ wsdlService.setServiceInterface(this.getBoundInterface(wsdlService));
+ WSDLEndpoint wsdlEndpoint;
+ Port wsdl4jPort;
+ while (wsdl4jportsIterator.hasNext()) {
+ wsdlEndpoint = this.wsdlComponenetFactory.createEndpoint();
+ wsdl4jPort = (Port) wsdl4jportsIterator.next();
+ this.populatePorts(wsdlEndpoint,
+ wsdl4jPort,
+ wsdl4jService.getQName().getNamespaceURI());
+ this.copyExtensibleElements(wsdl4jPort.getExtensibilityElements(),
+ wsdlEndpoint);
+ wsdlService.setEndpoint(wsdlEndpoint);
+ }
+
+ }
+
+ /////////////////////////////////////////////////////////////////////////////
+ //////////////////////////// Internal Component Copying ///////////////////
+ //TODO Faults
+ public void populateOperations(WSDLOperation wsdlOperation,
+ Operation wsdl4jOperation, String nameSpaceOfTheOperation) {
+ //Copy Name Attrebute
+ wsdlOperation.setName(new QName(nameSpaceOfTheOperation,
+ wsdl4jOperation.getName()));
+
+ //This code make no attempt to make use of the special xs:Token
+ //defined in the WSDL 2.0. eg like #any, #none
+ // Create the Input Message and add
+ Input wsdl4jInputMessage = wsdl4jOperation.getInput();
+
+ if(null != wsdl4jInputMessage){
+ MessageReference wsdlInputMessage = this.wsdlComponenetFactory
+ .createMessageReference();
+ wsdlInputMessage.setDirection(WSDLConstants.WSDL_MESSAGE_DIRECTION_IN);
+ wsdlInputMessage.setMessageLabel(WSDLConstants.MESSAGE_LABEL_IN_VALUE);
+ wsdlInputMessage.setElement(this.generateReferenceQname(wsdl4jInputMessage.getMessage()));
+ this.copyExtensibleElements(
+ (wsdl4jInputMessage.getMessage()).getExtensibilityElements(),
+ wsdlInputMessage
+ );
+ this.copyExtensibilityAttribute(wsdl4jInputMessage.getExtensionAttributes(),
+ wsdlInputMessage);
+ wsdlOperation.setInputMessage(wsdlInputMessage);
+ }
+
+ //Create an output message and add
+ Output wsdl4jOutputMessage = wsdl4jOperation.getOutput();
+ if(null != wsdl4jOutputMessage){
+ MessageReference wsdlOutputMessage =
+ this.wsdlComponenetFactory.createMessageReference();
+ wsdlOutputMessage.setDirection(WSDLConstants.WSDL_MESSAGE_DIRECTION_OUT);
+ wsdlOutputMessage.setMessageLabel(WSDLConstants.MESSAGE_LABEL_OUT_VALUE);
+
+ wsdlOutputMessage.setElement(this.generateReferenceQname(wsdl4jOutputMessage.getMessage()));
+ this.copyExtensibleElements(
+ (wsdl4jOutputMessage.getMessage()).getExtensibilityElements(),
+ wsdlOutputMessage
+ );
+ this.copyExtensibilityAttribute(wsdl4jOutputMessage.getExtensionAttributes(),
+ wsdlOutputMessage);
+ wsdlOperation.setOutputMessage(wsdlOutputMessage);
+ }
+
+ Map faults = wsdl4jOperation.getFaults();
+ Iterator faultKeyIterator = faults.keySet().iterator();
+ WSDLFaultReference faultReference = null;
+
+ while(faultKeyIterator.hasNext()){
+
+ Fault fault = (Fault)faults.get(faultKeyIterator.next());
+ faultReference = wsdlComponenetFactory.createFaultReference();
+ faultReference.setDirection(WSDLConstants.WSDL_MESSAGE_DIRECTION_OUT);
+ faultReference.setRef(this.generateReferenceQname(fault.getMessage()));
+ wsdlOperation.addOutFault(faultReference);
+ this.copyExtensibilityAttribute(fault.getExtensionAttributes(), faultReference);
+ //TODO Fault Message lable
+
+ }
+
+ //Set the MEP
+ wsdlOperation.setMessageExchangePattern(WSDL11MEPFinder
+ .getMEP(wsdl4jOperation));
+
+ }
+ private QName generateReferenceQname(Message wsdl4jMessage){
+ QName referenceQName = null;
+ if (wsdl4jMessage.getParts().size() > 1){
+ // Multipart Message
+
+ // Check whether this message parts have been made to a type
+ Iterator multipartListIterator = this.resolvedMultipartMessageList.iterator();
+ boolean multipartAlreadyResolved = false;
+ while(multipartListIterator.hasNext() && !multipartAlreadyResolved){
+ QName temp = (QName)multipartListIterator.next();
+ multipartAlreadyResolved = wsdl4jMessage.getQName().equals(temp);
+ }
+ if(multipartAlreadyResolved){
+ //This message with multiple parts has resolved and a new type has been
+ //made out of it earlier.
+ //FIXME Actual element name should it be xs:, if yes change the qname added to the
+ //resolvedmessage list too.
+ referenceQName = wsdl4jMessage.getQName();
+ }else{
+ //Get the list of multiparts of the message and create a new Element
+ //out of it and add it to the schema.
+ Map parts = wsdl4jMessage.getParts();
+ Element element = null;
+ WSDLTypes types = womDefinition.getTypes();
+ if(null == types){
+ XmlDocument newDoc = new XmlDocument();
+
+ Element schemaElement = newDoc.createElement("schema");//http://www.w3.org/2001/XMLSchema
+ types =wsdlComponenetFactory.createTypes();
+ ExtensionFactory extensionFactory = wsdlComponenetFactory.createExtensionFactory();
+ org.apache.wsdl.extensions.Schema typesElement = (org.apache.wsdl.extensions.Schema)extensionFactory.getExtensionElement(ExtensionConstants.SCHEMA);
+ typesElement.setElelment(schemaElement);
+ types.addExtensibilityElement(typesElement);
+ this.womDefinition.setTypes(types);
+ }
+ Iterator schemaEIIterator = types.getExtensibilityElements().iterator();
+ while(schemaEIIterator.hasNext()){
+ WSDLExtensibilityElement temp = (WSDLExtensibilityElement)schemaEIIterator.next();
+ if(ExtensionConstants.SCHEMA.equals(temp.getType())){
+ element = ((org.apache.wsdl.extensions.Schema)temp).getElelment();
+ break;
+ }
+ }
+
+ Document doc = element.getOwnerDocument();
+ String name = wsdl4jMessage.getQName().getLocalPart();
+ Element newElement = doc.createElement("complexType");
+ newElement.setAttribute("name", name);
+
+ Element cmplxContent = doc.createElement("complexContent");
+ Element child;
+ Iterator iterator = parts.keySet().iterator();
+ while(iterator.hasNext()){
+ Part part = (Part)parts.get(iterator.next());
+ QName elementName = part.getElementName();
+ if(null == elementName){
+ elementName = part.getTypeName();
+ }
+
+
+ child = doc.createElement("element");
+ child.setAttribute("name", "var"+elementName.getLocalPart());
+ child.setAttribute("type", elementName.getNamespaceURI()+":"+elementName.getLocalPart());
+ cmplxContent.appendChild(child);
+ }
+
+
+ newElement.appendChild(cmplxContent);
+
+ element.appendChild(newElement);
+ //Now since a new type is created augmenting the parts add the QName
+ //of the newly created type as the messageReference's name.
+ referenceQName = wsdl4jMessage.getQName();
+ //Add this message as a resolved message, so that incase some other
+ //operation refer to the same message the if above will take a hit
+ //and the cashed QName can be used instead of crating another type
+ //for the same message.
+
+ this.resolvedMultipartMessageList.add(wsdl4jMessage.getQName());
+
+ }
+ }else{
+ //Only one part so copy the QName of the referenced type.
+ Iterator outputIterator =
+ wsdl4jMessage.getParts().values().iterator();
+ if (outputIterator.hasNext()) {
+ Part outPart = ((Part) outputIterator.next());
+ QName typeName;
+ if (null != (typeName = outPart.getTypeName())) {
+ referenceQName = typeName;
+ } else {
+ referenceQName = outPart.getElementName();
+ }
+ }
+ }
+ return referenceQName;
+ }
+
+ private void populateBindingOperation(
+ WSDLBindingOperation wsdlBindingOperation,
+ BindingOperation wsdl4jBindingOperation,
+ String nameSpaceOfTheBindingOperation) {
+
+ wsdlBindingOperation.setName(new QName(nameSpaceOfTheBindingOperation,
+ wsdl4jBindingOperation.getName()));
+ BindingInput wsdl4jInputBinding =
+ wsdl4jBindingOperation.getBindingInput();
+ if(null != wsdl4jInputBinding){
+ WSDLBindingMessageReference wsdlInputBinding =
+ this.wsdlComponenetFactory.createWSDLBindingMessageReference();
+ wsdlInputBinding.setDirection(WSDLConstants.WSDL_MESSAGE_DIRECTION_IN);
+ //TODO Faults
+ this.copyExtensibleElements(wsdl4jInputBinding.getExtensibilityElements(),
+ wsdlInputBinding);
+ wsdlBindingOperation.setInput(wsdlInputBinding);
+ }
+
+ BindingOutput wsdl4jOutputBinding = wsdl4jBindingOperation
+ .getBindingOutput();
+ if(null != wsdl4jOutputBinding){
+ WSDLBindingMessageReference wsdlOutputBinding = this.wsdlComponenetFactory
+ .createWSDLBindingMessageReference();
+
+ wsdlOutputBinding.setDirection(WSDLConstants.WSDL_MESSAGE_DIRECTION_OUT);
+ //TODO Faults
+ this.copyExtensibleElements(wsdl4jOutputBinding.getExtensibilityElements(),
+ wsdlOutputBinding);
+ wsdlBindingOperation.setOutput(wsdlOutputBinding);
+ }
+
+
+ Map bindingFaults = wsdl4jBindingOperation.getBindingFaults();
+ Iterator keyIterator = bindingFaults.keySet().iterator();
+ while(keyIterator.hasNext()){
+ BindingFault bindingFault = (BindingFault)bindingFaults.get(keyIterator.next());
+ WSDLBindingFault womBindingFault = this.wsdlComponenetFactory.createBindingFault();
+ this.copyExtensibleElements(bindingFault.getExtensibilityElements(), womBindingFault);
+ wsdlBindingOperation.addOutFault(womBindingFault);
+ }
+
+ }
+
+ public void populatePorts(WSDLEndpoint wsdlEndpoint, Port wsdl4jPort,
+ String targetNamspace) {
+ wsdlEndpoint.setName(new QName(targetNamspace, wsdl4jPort.getName()));
+
+ wsdlEndpoint.setBinding(this.womDefinition.getBinding(wsdl4jPort
+ .getBinding().getQName()));
+
+ }
+
+ /**
+ * This method will fill up the gap of WSDL 1.1 and WSDL 2.0 w.r.t. the
+ * bound interface for the Service Component Defined in the WSDL 2.0. Logic
+ * being if there exist only one PortType in the WSDL 1.1 file then that
+ * will be set as the bound interface of the Service. If more than one
+ * Porttype exist in the WSDl 1.1 file this will create a dummy Interface
+ * with the available PortTypes and will return that interface so that it
+ * will inherit all those interfaces.
+ *
+ * Eventuall this will have to be fixed using user input since
+ *
+ * @param service
+ * @return
+ */
+ private WSDLInterface getBoundInterface(WSDLService service) {
+
+ // Throw an exception if there are no interfaces defined as at yet.
+ if (0 == this.womDefinition.getWsdlInterfaces().size())
+ throw new WSDLProcessingException(
+ "There are no "
+ + "Interfaces/PortTypes identified in the current partially built"
+ + "WOM");
+
+ //If there is only one Interface available hten return that because
+ // normally
+ // that interface must be the one to the service should get bound.
+ if (1 == this.womDefinition.getWsdlInterfaces().size())
+ return (WSDLInterface) this.womDefinition.getWsdlInterfaces()
+ .values().iterator().next();
+
+ //If there are more than one interface available... For the time being
+ // create a
+ // new interface and set all those existing interfaces as
+ // superinterfaces of it
+ // and return.
+ WSDLInterface newBoundInterface = this.womDefinition.createInterface();
+ newBoundInterface.setName(new QName(service.getNamespace(), service
+ .getName().getLocalPart()
+ + BOUND_INTERFACE_NAME));
+ Iterator interfaceIterator = this.womDefinition.getWsdlInterfaces()
+ .values().iterator();
+ while (interfaceIterator.hasNext()) {
+ newBoundInterface
+ .addSuperInterface((WSDLInterface) interfaceIterator.next());
+ }
+ return newBoundInterface;
+ }
+
+ /**
+ * Get the Extensible elements form wsdl4jExtensibleElements
+ * <code>Vector</code> if any and copy them to <code>Component</code>
+ *
+ * @param wsdl4jExtensibleElements
+ * @param womExtensibleElements
+ */
+ private void copyExtensibleElements(List wsdl4jExtensibleElements,
+ Component component) {
+ Iterator iterator = wsdl4jExtensibleElements.iterator();
+ ExtensionFactory extensionFactory = this.wsdlComponenetFactory
+ .createExtensionFactory();
+ while (iterator.hasNext()) {
+
+ ExtensibilityElement wsdl4jElement = (ExtensibilityElement) iterator
+ .next();
+
+ if (wsdl4jElement instanceof UnknownExtensibilityElement) {
+ UnknownExtensibilityElement unknown = (UnknownExtensibilityElement) (wsdl4jElement);
+ DefaultExtensibilityElement extensibilityElement = (DefaultExtensibilityElement) extensionFactory
+ .getExtensionElement(wsdl4jElement.getElementType());
+ extensibilityElement.setElement(unknown.getElement());
+ Boolean required = unknown.getRequired();
+ if (null != required) {
+ extensibilityElement.setRequired(required.booleanValue());
+ }
+ component.addExtensibilityElement(extensibilityElement);
+ } else if (wsdl4jElement instanceof SOAPAddress) {
+ SOAPAddress soapAddress = (SOAPAddress) wsdl4jElement;
+ org.apache.wsdl.extensions.SOAPAddress extensibilityElement = (org.apache.wsdl.extensions.SOAPAddress) extensionFactory
+ .getExtensionElement(soapAddress.getElementType());
+ extensibilityElement.setLocationURI(soapAddress
+ .getLocationURI());
+ Boolean required = soapAddress.getRequired();
+ if (null != required) {
+ extensibilityElement.setRequired(required.booleanValue());
+ }
+ component.addExtensibilityElement(extensibilityElement);
+ }else if(wsdl4jElement instanceof Schema) {
+ Schema schema = (Schema)wsdl4jElement;
+ org.apache.wsdl.extensions.Schema extensibilityElement = (org.apache.wsdl.extensions.Schema)extensionFactory.getExtensionElement(schema.getElementType());
+ extensibilityElement.setElelment(schema.getElement());
+ Boolean required = schema.getRequired();
+ if(null != required){
+ extensibilityElement.setRequired(required.booleanValue());
+ }
+ component.addExtensibilityElement(extensibilityElement);
+ }else if(SOAPConstants.Q_ELEM_SOAP_OPERATION.equals(wsdl4jElement.getElementType())){
+ SOAPOperation soapOperation = (SOAPOperation)wsdl4jElement;
+ org.apache.wsdl.extensions.SOAPOperation extensibilityElement = (org.apache.wsdl.extensions.SOAPOperation)extensionFactory.getExtensionElement(soapOperation.getElementType());
+ extensibilityElement.setSoapAction(soapOperation.getSoapActionURI());
+ extensibilityElement.setStyle(soapOperation.getStyle());
+ Boolean required = soapOperation.getRequired();
+ if(null != required){
+ extensibilityElement.setRequired(required.booleanValue());
+ }
+ component.addExtensibilityElement(extensibilityElement);
+ }else if(SOAPConstants.Q_ELEM_SOAP_BODY.equals(wsdl4jElement.getElementType())){
+ SOAPBody soapBody = (SOAPBody)wsdl4jElement;
+ org.apache.wsdl.extensions.SOAPBody extensibilityElement = (org.apache.wsdl.extensions.SOAPBody)extensionFactory.getExtensionElement(soapBody.getElementType());
+ extensibilityElement.setNamespaceURI(soapBody.getNamespaceURI());
+ extensibilityElement.setUse(soapBody.getUse());
+ Boolean required = soapBody.getRequired();
+ if(null != required){
+ extensibilityElement.setRequired(required.booleanValue());
+ }
+ component.addExtensibilityElement(extensibilityElement);
+ }else if(SOAPConstants.Q_ELEM_SOAP_BINDING.equals(wsdl4jElement.getElementType())){
+ SOAPBinding soapBinding = (SOAPBinding)wsdl4jElement;
+ org.apache.wsdl.extensions.SOAPBinding extensibilityElement = (org.apache.wsdl.extensions.SOAPBinding)extensionFactory.getExtensionElement(soapBinding.getElementType());
+ extensibilityElement.setTransportURI(soapBinding.getTransportURI());
+ extensibilityElement.setStyle(soapBinding.getStyle());
+ Boolean required = soapBinding.getRequired();
+ if(null != required){
+ extensibilityElement.setRequired(required.booleanValue());
+ }
+ component.addExtensibilityElement(extensibilityElement);
+ }else {
// throw new AxisError(
// "An Extensible item "+wsdl4jElement.getElementType()+" went unparsed during WSDL Parsing");
- }
- }
- }
-
- /**
- * Get the Extensible Attributes from wsdl4jExtensibilityAttribute
- * <code>Map</code> if any and copy them to the <code>Component</code>
- *
- * @param wsdl4jExtensibilityAttributes
- * @param component
- */
- private void copyExtensibilityAttribute(Map wsdl4jExtensibilityAttributes,
- Component component) {
- Iterator iterator = wsdl4jExtensibilityAttributes.keySet().iterator();
- while (iterator.hasNext()) {
- QName attributeName = (QName) iterator.next();
- QName value = (QName) wsdl4jExtensibilityAttributes
- .get(attributeName);
- WSDLExtensibilityAttribute attribute = this.wsdlComponenetFactory
- .createWSDLExtensibilityAttribute();
- attribute.setKey(attributeName);
- attribute.setValue(value);
- component.addExtensibleAttributes(attribute);
- }
- }
+ }
+ }
+ }
+
+ /**
+ * Get the Extensible Attributes from wsdl4jExtensibilityAttribute
+ * <code>Map</code> if any and copy them to the <code>Component</code>
+ *
+ * @param wsdl4jExtensibilityAttributes
+ * @param component
+ */
+ private void copyExtensibilityAttribute(Map wsdl4jExtensibilityAttributes,
+ Component component) {
+ Iterator iterator = wsdl4jExtensibilityAttributes.keySet().iterator();
+ while (iterator.hasNext()) {
+ QName attributeName = (QName) iterator.next();
+ QName value = (QName) wsdl4jExtensibilityAttributes
+ .get(attributeName);
+ WSDLExtensibilityAttribute attribute = this.wsdlComponenetFactory
+ .createWSDLExtensibilityAttribute();
+ attribute.setKey(attributeName);
+ attribute.setValue(value);
+ component.addExtensibleAttributes(attribute);
+ }
+ }
}
Modified: webservices/axis/trunk/java/modules/wsdl/src/org/apache/axis/wsdl/codegen/emitter/MultiLanguageClientEmitter.java
URL: http://svn.apache.org/viewcvs/webservices/axis/trunk/java/modules/wsdl/src/org/apache/axis/wsdl/codegen/emitter/MultiLanguageClientEmitter.java?rev=202314&r1=202313&r2=202314&view=diff
==============================================================================
--- webservices/axis/trunk/java/modules/wsdl/src/org/apache/axis/wsdl/codegen/emitter/MultiLanguageClientEmitter.java (original)
+++ webservices/axis/trunk/java/modules/wsdl/src/org/apache/axis/wsdl/codegen/emitter/MultiLanguageClientEmitter.java Tue Jun 28 21:14:13 2005
@@ -36,11 +36,15 @@
import org.apache.wsdl.WSDLOperation;
import org.apache.wsdl.WSDLService;
import org.apache.wsdl.WSDLTypes;
+import org.apache.wsdl.WSDLBindingOperation;
import org.apache.wsdl.extensions.ExtensionConstants;
+import org.apache.wsdl.extensions.SOAPOperation;
import org.w3c.dom.Attr;
import org.w3c.dom.Element;
import org.w3c.dom.Text;
+import javax.wsdl.extensions.ExtensibilityElement;
+
/*
@@ -500,12 +504,7 @@
fillSyncAttributes(doc, rootElement);
loadOperations(boundInterface, doc, rootElement);
doc.appendChild(rootElement);
- try {
- doc.write(System.out);
- } catch (IOException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
+
return doc;
}
/**
@@ -538,10 +537,10 @@
}
private void loadOperations(WSDLInterface boundInterface, XmlDocument doc, Element rootElement){
- loadOperations(boundInterface, doc, rootElement, null, null);
+ loadOperations(boundInterface, doc, rootElement, null);
}
- private void loadOperations(WSDLInterface boundInterface, XmlDocument doc, Element rootElement, String operationPrefix, String operationPostfix) {
+ private void loadOperations(WSDLInterface boundInterface, XmlDocument doc, Element rootElement,WSDLBindingOperation binding) {
Collection col = boundInterface.getOperations().values();
Element methodElement = null;
WSDLOperation operation = null;
@@ -554,6 +553,7 @@
addAttribute(doc,"namespace",operation.getName().getNamespaceURI(),methodElement);
addAttribute(doc,"style",operation.getStyle(),methodElement);
addAttribute(doc,"dbsupportname",localPart+DATABINDING_SUPPORTER_NAME_SUFFIX,methodElement);
+ addSOAPAction(doc,methodElement,binding);
addAttribute(doc, "mep",operation.getMessageExchangePattern(), methodElement);
methodElement.appendChild(getInputElement(doc,operation));
methodElement.appendChild(getOutputElement(doc,operation));
@@ -561,6 +561,22 @@
}
}
+ private void addSOAPAction(XmlDocument doc,Element rootElement,WSDLBindingOperation binding){
+ Iterator extIterator = binding.getExtensibilityElements().iterator();
+ boolean actionAdded = false;
+ while(extIterator.hasNext()){
+ ExtensibilityElement element = (ExtensibilityElement)extIterator.next();
+ if(element.getElementType().equals(ExtensionConstants.SOAP_OPERATION)){
+ addAttribute(doc,"soapaction", ((SOAPOperation)element).getSoapAction(),rootElement);
+ actionAdded = true ;
+ }
+ }
+
+ if (!actionAdded){
+ addAttribute(doc,"soapaction", "",rootElement);
+ }
+ }
+
protected XmlDocument createDOMDocuementForTestCase(WSDLBinding binding) {
WSDLInterface boundInterface = binding.getBoundInterface();
@@ -642,6 +658,17 @@
fillSyncAttributes(doc, rootElement);
loadOperations(boundInterface, doc, rootElement);
doc.appendChild(rootElement);
+
+ //////////////////////////
+// try {
+// doc.write(System.out);
+// } catch (IOException e) {
+// e.printStackTrace(); //To change body of catch statement use File | Settings | File Templates.
+// }
+
+ ///////////////////////////////
+
+
return doc;
}
Modified: webservices/axis/trunk/java/modules/wsdl/src/org/apache/axis/wsdl/template/java/InterfaceImplementationTemplate.xsl
URL: http://svn.apache.org/viewcvs/webservices/axis/trunk/java/modules/wsdl/src/org/apache/axis/wsdl/template/java/InterfaceImplementationTemplate.xsl?rev=202314&r1=202313&r2=202314&view=diff
==============================================================================
--- webservices/axis/trunk/java/modules/wsdl/src/org/apache/axis/wsdl/template/java/InterfaceImplementationTemplate.xsl (original)
+++ webservices/axis/trunk/java/modules/wsdl/src/org/apache/axis/wsdl/template/java/InterfaceImplementationTemplate.xsl Tue Jun 28 21:14:13 2005
@@ -61,6 +61,7 @@
<xsl:variable name="inputtype"><xsl:value-of select="input/param/@type"></xsl:value-of></xsl:variable> <!-- this needs to change-->
<xsl:variable name="inputparam"><xsl:value-of select="input/param/@name"></xsl:value-of></xsl:variable> <!-- this needs to change-->
<xsl:variable name="dbsupportclassname"><xsl:value-of select="@dbsupportname"></xsl:value-of></xsl:variable>
+ <xsl:variable name="soapAction"><xsl:value-of select="@soapaction"></xsl:value-of></xsl:variable>
<!-- When genrating code, the MEP should be taken into account -->
@@ -74,7 +75,7 @@
org.apache.axis.clientapi.Call _call = new org.apache.axis.clientapi.Call(_serviceContext);
org.apache.axis.context.MessageContext _messageContext = getMessageContext();
- _call.setTo(toEPR);
+ _call.setTo(toEPR);
org.apache.axis.soap.SOAPEnvelope env = null;
env = createEnvelope();
//create a databinder
Modified: webservices/axis/trunk/java/modules/wsdl/src/org/apache/axis/wsdl/template/java/XMLBeansSupporterTemplate.xsl
URL: http://svn.apache.org/viewcvs/webservices/axis/trunk/java/modules/wsdl/src/org/apache/axis/wsdl/template/java/XMLBeansSupporterTemplate.xsl?rev=202314&r1=202313&r2=202314&view=diff
==============================================================================
--- webservices/axis/trunk/java/modules/wsdl/src/org/apache/axis/wsdl/template/java/XMLBeansSupporterTemplate.xsl (original)
+++ webservices/axis/trunk/java/modules/wsdl/src/org/apache/axis/wsdl/template/java/XMLBeansSupporterTemplate.xsl Tue Jun 28 21:14:13 2005
@@ -27,12 +27,18 @@
}
//Generates an empty object for testing
+ // Caution - may need some manual editing to wrk properly
public org.apache.xmlbeans.XmlObject getTestObject(java.lang.Class type){
try{
<xsl:for-each select="param">
<xsl:if test="@type!=''">
if (<xsl:value-of select="@type"/>.class.equals(type)){
- return <xsl:value-of select="@type"/>.Factory.newInstance() ;
+ <xsl:value-of select="@type"/> emptyObject= <xsl:value-of select="@type"/>.Factory.newInstance();
+ ////////////////////////////////////////////////
+ // TODO
+ // Fill in the empty object with necessaey values. Empty XMLBeans objects do not generate proper events
+ ////////////////////////////////////////////////
+ return emptyObject;
}
</xsl:if>
</xsl:for-each>
@@ -48,8 +54,11 @@
<xsl:if test="@type!=''">
public org.apache.axis.om.OMElement toOM(<xsl:value-of select="@type"/> param){
org.apache.axis.om.impl.llom.builder.StAXOMBuilder builder = org.apache.axis.om.impl.llom.factory.OMXMLBuilderFactory.createStAXOMBuilder
- (org.apache.axis.om.OMAbstractFactory.getOMFactory(),param.newXMLStreamReader()) ;
- return builder.getDocumentElement();
+ (org.apache.axis.om.OMAbstractFactory.getOMFactory(),new org.apache.axis.clientapi.StreamWrapper(param.newXMLStreamReader())) ;
+ org.apache.axis.om.OMElement documentElement = builder.getDocumentElement();
+ //Building the element is needed to avoid certain stream errors!
+ documentElement.build();
+ return documentElement;
}
</xsl:if>
</xsl:template>