Dan,
Knew you'd get back to me quick. I apologize for not stating it earlier,
but yes, i am on a Windows system. IMHO this shouldn't prevent such a wsdl
from content being generated. I know that if the Message and a complex type
have the same name, the complex type is named "..Type" to distinguish it
from the message. I'd have thought that the portType collision would do the
same thing.
I ran the command you suggested and here's the outtput:
Generating code...
[ERROR] Could not generate SEI, class: edu.umkc.cse.cs5551.ws.CREATERECIPE
already exists. Rename wsdl:portType "{
http://ws.cs5551.cse.umkc.edu/}CREATE_RECIPE" using JAX-WS customization
line 35 of file:/C:/testservice/src/main/resources/recipeservice.wsdl
I was able to give that bindings configuration a shot and it got me past
that issue, but since i'm building a client its now naming the client the
same thing as the complex type. I'll try to see if i can't create a binding
for the complex type to add "type" so as to get past this issue too.
Thanks for the quick response & help!
-B
On Tue, Feb 21, 2012 at 2:21 PM, Daniel Kulp <[email protected]> wrote:
> On Tuesday, February 21, 2012 12:43:40 PM Bryan Stopp wrote:
> > Hello all,
> >
> > I'm trying to use wsdl2java to create a client for a WS. The WS is built
> > using an SAP SOA/ESB tool (not too sure). In any event, the Port Type
> > defined in the WSDL, and one of the complex types have the same name,
> sorta.
> >
> > The port type is all uppercase and has underscores in it, the complex
> type
> > is a standard name.
> >
> > This poses a problem for the wsdl2java tool as it uses these names (minus
> > namespace) tweaks them, and generates the resulting classes. What ends up
> > happening is i get the Service created and no parameter object, and the
> > wsdl2java call actually fails quietly.
>
> Just tried it on Linux and it generated both fine, but I have a feeling
> it's
> because Linux uses a case sensitive file system. Thus, I ended up with:
>
> CREATERECIPE.java
> CreateRecipe.java
>
> which, on Linux, is perfectly valid and quite usable. I assume you are
> either on Windows or Mac?
>
> I also tried the wsimport command from the Java6 JDK and it generated the
> same
> thing (and also no warning or anything). Thus, this really is "per spec",
> but
> kind of strange. Can you run "wsimport -keep recipeservice.wsdl" from the
> command line and see what it does on your machine? I'm curious to see
> what
> it generates.
>
> Most likely, since this is per spec and it does generate usable code on
> some
> environments, it's current behavior is "proper". We could likely emit a
> warning.
>
> You CAN use a jaxws binding file to rename the service. Create a file
> like:
>
>
> <jaxws:bindings xmlns:jaxws="http://java.sun.com/xml/ns/jaxws"
> xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/">
> <jaxws:bindings
> node="wsdl:definitions/wsdl:portType[@name='CREATE_RECIPE']">
> <jaxws:class name="CreateRecipeSEI"/>
> </jaxws:bindings>
> </jaxws:bindings>
>
>
> and pass that into wsdl2java with the -b flag (bindingFiles)
>
> Dan
>
>
>
> > I was able to recreate the issue with a dummy wsdl i had laying around
> from
> > one of my classes:
> >
> > Here's the WSDL
> >
> > <?xml version="1.0" encoding="UTF-8"?>
> > <wsdl:definitions name="JaxWsCreateRecipeWsService" targetNamespace="
> > http://ws.cs5551.cse.umkc.edu/" xmlns:ns1="
> > http://schemas.xmlsoap.org/soap/http" xmlns:soap="
> > http://schemas.xmlsoap.org/wsdl/soap/" xmlns:tns="
> > http://ws.cs5551.cse.umkc.edu/"
> > xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
> > xmlns:xsd="http://www.w3.org/2001/XMLSchema">
> > <wsdl:types>
> > <xs:schema elementFormDefault="unqualified" targetNamespace="
> > http://ws.cs5551.cse.umkc.edu/" version="1.0" xmlns:tns="
> > http://ws.cs5551.cse.umkc.edu/" xmlns:xs="
> http://www.w3.org/2001/XMLSchema">
> > <xs:element name="createRecipe" type="tns:createRecipe"/>
> > <xs:element name="createRecipeResponse" type="tns:createRecipeResponse"/>
> > <xs:complexType name="createRecipe">
> > <xs:sequence>
> > <xs:element minOccurs="0" name="recipe" type="tns:recipe"/>
> > </xs:sequence>
> > </xs:complexType>
> > <xs:complexType name="recipe">
> > <xs:sequence>
> > <xs:element minOccurs="0" name="id" type="xs:long"/>
> > <xs:element minOccurs="0" name="image" type="xs:string"/>
> > <xs:element minOccurs="0" name="name" type="xs:string"/>
> > <xs:element minOccurs="0" name="prepTime" type="xs:int"/>
> > </xs:sequence>
> > </xs:complexType>
> > <xs:complexType name="createRecipeResponse">
> > <xs:sequence>
> > <xs:element minOccurs="0" name="recipe" type="tns:recipe"/>
> > </xs:sequence>
> > </xs:complexType>
> > </xs:schema>
> > </wsdl:types>
> > <wsdl:message name="createRecipeResponse">
> > <wsdl:part element="tns:createRecipeResponse" name="parameters">
> > </wsdl:part>
> > </wsdl:message>
> > <wsdl:message name="createRecipe">
> > <wsdl:part element="tns:createRecipe" name="parameters">
> > </wsdl:part>
> > </wsdl:message>
> > <wsdl:portType name="CREATE_RECIPE">
> > <wsdl:operation name="createRecipe">
> > <wsdl:input message="tns:createRecipe" name="createRecipe">
> > </wsdl:input>
> > <wsdl:output message="tns:createRecipeResponse"
> > name="createRecipeResponse">
> > </wsdl:output>
> > </wsdl:operation>
> > </wsdl:portType>
> > <wsdl:binding name="JaxWsCreateRecipeWsServiceSoapBinding"
> > type="tns:CREATE_RECIPE">
> > <soap:binding style="document" transport="
> > http://schemas.xmlsoap.org/soap/http"/>
> > <wsdl:operation name="createRecipe">
> > <soap:operation soapAction="" style="document"/>
> > <wsdl:input >
> > <soap:body use="literal"/>
> > </wsdl:input>
> > <wsdl:output>
> > <soap:body use="literal"/>
> > </wsdl:output>
> > </wsdl:operation>
> > </wsdl:binding>
> > <wsdl:service name="JaxWsCreateRecipeWsService">
> > <wsdl:port binding="tns:JaxWsCreateRecipeWsServiceSoapBinding"
> > name="JaxWsCreateRecipeWsPort">
> > <soap:address location="
> > http://localhost:8080/recipe-ws/services/CreateRecipeService"/>
> > </wsdl:port>
> > </wsdl:service>
> > </wsdl:definitions>
> >
> >
> > Here's a maven pom.xml:
> >
> > <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="
> > http://www.w3.org/2001/XMLSchema-instance"
> > xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
> > http://maven.apache.org/xsd/maven-4.0.0.xsd">
> > <modelVersion>4.0.0</modelVersion>
> >
> > <groupId>test</groupId>
> > <artifactId>test-service</artifactId>
> > <packaging>jar</packaging>
> > <version>1.0.0-SNAPSHOT</version>
> >
> > <properties>
> > <cxf.version>2.4.1</cxf.version>
> >
> > </properties>
> >
> > <build>
> > <plugins>
> > <plugin>
> > <artifactId>maven-clean-plugin</artifactId>
> > <configuration>
> > <filesets>
> > <fileset>
> > <directory>src/main/java/com</directory>
> > <includes>
> > <include>**</include>
> > </includes>
> > </fileset>
> > </filesets>
> > </configuration>
> > </plugin>
> > <plugin>
> > <artifactId>maven-compiler-plugin</artifactId>
> > <configuration>
> > <source>1.6</source>
> > <target>1.6</target>
> > </configuration>
> > </plugin>
> > <plugin>
> > <groupId>org.apache.cxf</groupId>
> > <artifactId>cxf-codegen-plugin</artifactId>
> > <version>${cxf.version}</version>
> > <executions>
> > <execution>
> > <id>generate-sources</id>
> > <phase>generate-sources</phase>
> > <goals>
> > <goal>wsdl2java</goal>
> > </goals>
> > <configuration>
> > <sourceRoot>${basedir}/src/main/java</sourceRoot>
> > <wsdlOptions>
> > <wsdlOption>
> > <wsdl> ${basedir}/src/main/resources/recipeservice.wsdl</wsdl>
> > <extraargs>
> > <extraarg>-wsdlLocation</extraarg>
> > <extraarg>classpath:recipeservice.wsdl</extraarg>
> > <extraarg>-client</extraarg>
> > <extraarg>-server</extraarg>
> > <extraarg>-impl</extraarg>
> > <extraarg>-frontend</extraarg>
> > <extraarg>jaxws21</extraarg>
> > </extraargs>
> > </wsdlOption>
> > </wsdlOptions>
> > </configuration>
> > </execution>
> > </executions>
> > </plugin>
> > </plugins>
> > </build>
> >
> >
> > <dependencies>
> > <dependency>
> > <groupId>javax.jws</groupId>
> > <artifactId>jsr181-api</artifactId>
> > <version>1.0-MR1</version>
> > <type>jar</type>
> > <scope>provided</scope>
> > </dependency>
> >
> > <dependency>
> > <groupId>javax.xml.bind</groupId>
> > <artifactId>jaxb-api</artifactId>
> > <version>2.1</version>
> > <scope>provided</scope>
> > </dependency>
> > <dependency>
> > <groupId>javax.xml.ws</groupId>
> > <artifactId>jaxws-api</artifactId>
> > <version>2.1</version>
> > <scope>provided</scope>
> > </dependency>
> > </dependencies>
> > </project>
> >
> >
> >
> > If you run the generate-sources on it, you'll see what i'm referring to.
> >
> > Has anyone run into this problem before? Is there a fix for it? Is it an
> > issue of the wsdl2java too, or the cxf code gen tool?
> >
> > Obviously if i rename either the portType or the parameter element the
> > issue resolves itself, but i was just wondering if anyone knew if any of
> > the other parameters for configuring the wsdl2java tool could fix this, i
> > have yet to see anything that does.
> >
> > Thanks in advance!
> >
> > -B
> --
> Daniel Kulp
> [email protected] - http://dankulp.com/blog
> Talend Community Coder - http://coders.talend.com
>