axis-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Amila Suriarachchi" <amilasuriarach...@gmail.com>
Subject Re: wsdl2java namespace problem
Date Mon, 12 Nov 2007 09:55:50 GMT
On Nov 9, 2007 7:44 PM, Benoit Guillon <guillon@sungard-finance.fr> wrote:
>
> Hi,
>
> I'm having problems with the code generated by wsdl2java (precisely using
> the maven2 plugin). I'm using Axis2 1.3 with the ADB binding.
>
> It seems that the generator gets confused because an operation is declared
> in a given XML namespace and a bean used in the response of the operation is
> declared in a different namespace.
>
> The sample WSDL below illustrates the situation. The operation "timer" and
> its associated messages "timerRequest" and "timerResponse" belong to the
> namespace "http://mycompany.com/myservice" however the data structure
> ReturnStructure is defined with the namespace
> "http://mycompany.com/core/beans".
>
> In this situation, the generated code for the message TimerResponse expects
> an element ReturnStructure with namespace http://mycompany.com/myservice
> instead of "http://mycompany.com/core/beans".
>
> When the code is run, the parse method of TimerResponse class throws an
> ADBException "Unexepected subelement ReturnStructure" when the response is
> parsed.
>
> Is there something wrong with my WSDL (which is generated using another
> tool)? Or is this a bug?
>
> Help would be appreciated...
>
> Regards
>
> Benoit
>
> ======
>
> The part of my pom.xml that defines the use of the maven2 plugin:
>
> <build>
>         <plugins>
>                 <plugin>
>                 <groupId>org.apache.axis2</groupId>
>                 <artifactId>axis2-wsdl2code-maven-plugin</artifactId>
>                 <version>1.3</version>
>                 <executions>
>                         <execution>
>                         <goals>
>                                 <goal>wsdl2code</goal>
>                         </goals>
>                         <configuration>
>                                 <databindingName>adb</databindingName>
>                                 <packageName>org.mycompany.myservice.axis2client</packageName>
>                                 <wsdlFile>src/main/resources/myservice.wsdl</wsdlFile>
>
> <outputDirectory>target/generated-sources/axis2/wsdl2code</outputDirectory>
>                                 <unpackClasses>true</unpackClasses>
>                                 <syncMode>sync</syncMode>
>                         </configuration>
>                         </execution>
>                 </executions>
>                 </plugin>
>         </plugins>
> </build>
>
> ======
>
> The portion of code that causes the problem is located in TimerResponse.java
>
> if (reader.isStartElement() && new
> javax.xml.namespace.QName("http://mycompany.com/myservice","ReturnStructure").equals(reader.getName())){
>         nillableValue =

see you wsdl types section.
it has two schemas. the element timerResponse is defined in the second
schema and its targetnamespace
is http://mycompany.com/myservice.

so the generated code is correct.

thanks,
Amila.

> reader.getAttributeValue("http://www.w3.org/2001/XMLSchema-instance","nil");
>       if ("true".equals(nillableValue) || "1".equals(nillableValue)){
>         object.setReturnStructure(null);
>             reader.next();
>                 reader.next();
>
>         }else{
>
>
> object.setReturnStructure(com.mycompany.core.beans.ReturnStructure.Factory.parse(reader));
>
>                 reader.next();
>         }
> }  // End of if for expected property start element
>
> else{
>         // A start element we are not expecting indicates an invalid parameter was
> passed
>         throw new org.apache.axis2.databinding.ADBException("Unexpected subelement
> " + reader.getLocalName()); }
>
> =====
>
> The WSDL:
>
> <?xml version="1.0" encoding="UTF-8"?>
> <wsdl:definitions targetNamespace="http://mycompany.com/myservice"
> xmlns:tns="http://mycompany.com/myservice"
>         xmlns:wsdlsoap="http://schemas.xmlsoap.org/wsdl/soap/"
> xmlns:soap12="http://www.w3.org/2003/05/soap-envelope"
>         xmlns:ns1="http://mycompany.com/core/beans"
> xmlns:xsd="http://www.w3.org/2001/XMLSchema"
>         xmlns:soapenc11="http://schemas.xmlsoap.org/soap/encoding/"
> xmlns:soapenc12="http://www.w3.org/2003/05/soap-encoding"
>         xmlns:soap11="http://schemas.xmlsoap.org/soap/envelope/"
> xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/">
>         <wsdl:types>
>                 <schema xmlns="http://www.w3.org/2001/XMLSchema"
> elementFormDefault="qualified"
> targetNamespace="http://mycompany.com/core/beans">
>                         <complexType name="ReturnStructure">
>                                 <sequence>
>                                         <element maxOccurs="1" minOccurs="1" name="code"
type="int"></element>
>                                         <element maxOccurs="1" minOccurs="0" name="subCode"
> type="int"></element>
>                                         <element maxOccurs="1" minOccurs="0" name="message"
> type="string"></element>
>                                 </sequence>
>                         </complexType>
>
>                 </schema>
>                 <xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"
> attributeFormDefault="qualified" elementFormDefault="qualified"
> targetNamespace="http://mycompany.com/myservice">
>                         <xsd:element name="timer">
>                                 <xsd:complexType>
>                                         <xsd:sequence>
>                                                 <xsd:element maxOccurs="1" minOccurs="1"
name="nbExecutions"
> type="xsd:int" />
>                                                 <xsd:element maxOccurs="1" minOccurs="1"
name="lapDuration"
> type="xsd:int" />
>                                         </xsd:sequence>
>                                 </xsd:complexType>
>                         </xsd:element>
>                         <xsd:element name="timerResponse">
>                                 <xsd:complexType>
>                                         <xsd:sequence>
>                                                 <xsd:element maxOccurs="1" minOccurs="1"
name="ReturnStructure"
> nillable="true" type="ns1:ReturnStructure" />
>                                         </xsd:sequence>
>                                 </xsd:complexType>
>                         </xsd:element>
>                 </xsd:schema>
>         </wsdl:types>
>         <wsdl:message name="timerRequest">
>                 <wsdl:part name="parameters" element="tns:timer" />
>         </wsdl:message>
>         <wsdl:message name="timerResponse">
>                 <wsdl:part name="parameters" element="tns:timerResponse" />
>         </wsdl:message>
>         <wsdl:portType name="MyService">
>                 <wsdl:operation name="timer">
>                         <wsdl:input name="timerRequest" message="tns:timerRequest"
/>
>                         <wsdl:output name="timerResponse" message="tns:timerResponse"
/>
>                 </wsdl:operation>
>         </wsdl:portType>
>         <wsdl:binding name="MyServiceHttpBinding" type="tns:MyService">
>                 <wsdlsoap:binding style="document"
> transport="http://schemas.xmlsoap.org/soap/http" />
>                 <wsdl:operation name="timer">
>                         <wsdlsoap:operation soapAction="" />
>                         <wsdl:input name="timerRequest">
>                                 <wsdlsoap:body use="literal" />
>                         </wsdl:input>
>                         <wsdl:output name="timerResponse">
>                                 <wsdlsoap:body use="literal" />
>                         </wsdl:output>
>                 </wsdl:operation>
>         </wsdl:binding>
>         <wsdl:service name="MyService">
>                 <wsdl:port name="MyServiceHttpPort" binding="tns:MyServiceHttpBinding">
>                         <wsdlsoap:address location="http://myserver:30075/services/MyService"
/>
>                 </wsdl:port>
>         </wsdl:service>
> </wsdl:definitions>
>
>
>
>
> Benoît Guillon * NTIC * SunGard * Asset Arena Investment Accounting * 7 rue
> Royale, 173 Bureaux de la Colline, Bâtiment E, 92213 Saint-Cloud Cedex,
> France * Tel +33 1 49 11 31 87 * Fax +33 1 49 11 30 30 *
> www.sungard.com/assetarena
>
> --
> View this message in context: http://www.nabble.com/wsdl2java-namespace-problem-tf4777892.html#a13667692
> Sent from the Axis - User mailing list archive at Nabble.com.
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: axis-user-unsubscribe@ws.apache.org
> For additional commands, e-mail: axis-user-help@ws.apache.org
>
>



-- 
Amila Suriarachchi,
WSO2 Inc.

---------------------------------------------------------------------
To unsubscribe, e-mail: axis-user-unsubscribe@ws.apache.org
For additional commands, e-mail: axis-user-help@ws.apache.org


Mime
View raw message