I am attaching a modified AddressBook.wsdl that demonstrates the issue
that I
mentioned below. When I run wsdl2java on this wsdl file, I get the
following
exception:
java.io.IOException: Duplicate file name: AddressFetcher2/PhoneNumber.java.
Hint: you may have mapped two namespaces with elements of the same name
to the same package name.
at
org.apache.axis.wsdl.toJava.JavaWriter.generate(JavaWriter.java:139)
at
org.apache.axis.wsdl.toJava.JavaTypeWriter.generate(JavaTypeWriter.java:144)
at
org.apache.axis.wsdl.toJava.JavaGeneratorFactory$Writers.generate(JavaGeneratorFactory.java:286)
at org.apache.axis.wsdl.gen.Parser.generateTypes(Parser.java:357)
at org.apache.axis.wsdl.gen.Parser.generate(Parser.java:286)
at org.apache.axis.wsdl.gen.Parser.access$000(Parser.java:83)
at org.apache.axis.wsdl.gen.Parser$WSDLRunnable.run(Parser.java:248)
at
java.lang.Thread.run(Thread.java:536)
WSDL2Java is attempting to create 2 classes within the same namespace
(PhoneNumber.java).
Harish
Harish Prabandham wrote:
> When generating code for anonymous nested simpleTypes within a
> complexType in
> a schema definition, I noticed that WSDL2Java generates
> <elementName>.java,
> <elementName>Type0.java so on. For example, If there is a complexType
> with name
> foo and another complex type with bar both these complex types
> declare an
> anonymous simpletype element with a name "baz". The WSDL2Java generates
> Baz.java and BazType0.java so on.. It just seems that nested classes
> seems like an obvious solution for this. I was wondering why
> WSDL2Java does not generate
> nested classes instead.
>
> I also noticed that WSDL2Java generates a class even if all one does
> is add a
> pattern/length restriction - this seems very inefficient. Are there
> any plans to
> optimize/clean this up?
>
>
> Harish
>
<?xml version="1.0" ?>
<definitions name="urn:AddressFetcher"
targetNamespace="urn:AddressFetcher2"
xmlns:tns="urn:AddressFetcher2"
xmlns:typens="urn:AddressFetcher2"
xmlns:xsd="http://www.w3.org/1999/XMLSchema"
xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
xmlns="http://schemas.xmlsoap.org/wsdl/">
<!-- type defs -->
<types>
<xsd:schema targetNamespace="urn:AddressFetcher2"
xmlns:xsd="http://www.w3.org/1999/XMLSchema">
<xsd:simpleType name="stateType">
<xsd:restriction base="xsd:string">
<xsd:enumeration value="TX"/>
<xsd:enumeration value="IN"/>
<xsd:enumeration value="OH"/>
</xsd:restriction>
</xsd:simpleType>
<xsd:simpleType name="phoneNumber">
<xsd:restriction base="xsd:string">
<xsd:pattern value="(\d\d\d)\d\d\d-\d\d\d\d"/>
</xsd:restriction>
</xsd:simpleType>
<xsd:complexType name="phone">
<xsd:all>
<xsd:element name="areaCode" type="xsd:int"/>
<xsd:element name="exchange" type="xsd:string"/>
<xsd:element name="phoneNumber">
<xsd:simpleType>
<xsd:restriction base="xsd:string">
<xsd:pattern value="\d*{16}"/>
</xsd:restriction>
</xsd:simpleType>
</xsd:element>
</xsd:all>
</xsd:complexType>
<xsd:complexType name="address">
<xsd:all>
<xsd:element name="streetNum" type="xsd:int"/>
<xsd:element name="streetName" type="xsd:string"/>
<xsd:element name="city" type="xsd:string"/>
<xsd:element name="state" type="typens:stateType"/>
<xsd:element name="zip" type="xsd:int"/>
<xsd:element name="workPhone" type="typens:phoneNumber"/>
<xsd:element name="homePhone" type="typens:phone"/>
</xsd:all>
</xsd:complexType>
</xsd:schema>
</types>
<!-- message declns -->
<message name="AddEntryRequest">
<part name="name" type="xsd:string"/>
<part name="address" type="typens:address"/>
</message>
<message name="GetAddressFromNameRequest">
<part name="name" type="xsd:string"/>
</message>
<message name="GetAddressFromNameResponse">
<part name="address" type="typens:address"/>
</message>
<!-- port type declns -->
<portType name="AddressBook">
<operation name="addEntry">
<input message="tns:AddEntryRequest"/>
</operation>
<operation name="getAddressFromName">
<input message="tns:GetAddressFromNameRequest"/>
<output message="tns:GetAddressFromNameResponse"/>
</operation>
</portType>
<!-- binding declns -->
<binding name="AddressBookSOAPBinding" type="tns:AddressBook">
<soap:binding style="rpc"
transport="http://schemas.xmlsoap.org/soap/http"/>
<operation name="addEntry">
<soap:operation soapAction=""/>
<input>
<soap:body use="literal"/>
<!--
<soap:body use="encoded"
namespace="urn:AddressFetcher2"
encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/>
-->
</input>
<output>
<soap:body use="literal"/>
<!--
<soap:body use="encoded"
namespace="urn:AddressFetcher2"
encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/>
-->
</output>
</operation>
<operation name="getAddressFromName">
<soap:operation soapAction=""/>
<input>
<soap:body use="literal"/>
<!--
<soap:body use="encoded"
namespace="urn:AddressFetcher2"
encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/>
-->
</input>
<output>
<soap:body use="literal"/>
<!--
<soap:body use="encoded"
namespace="urn:AddressFetcher2"
encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/>
-->
</output>
</operation>
</binding>
<!-- service decln -->
<service name="AddressBookService">
<port name="AddressBook" binding="tns:AddressBookSOAPBinding">
<soap:address location="http://localhost:8080/axis/services/AddressBook"/>
</port>
</service>
</definitions>