Hi,

Am hoping someone can give me a hand with a potential issue (or a
misunderstanding on my part) with java2ws with respect to the target
namespaces being generated for the operation message types.

Some background: We have a requirement to move roughly 15 web services from
"Code-First" to "Contract-First".  In addition, we now need to collapse
these 15 web services into 1 big WSDL (not my choice).  To date we have been
using java2ws via the cxf-java2ws-plugin (2.3.1) to generate the WSDL for
each of our services.

Now, to boil this (potential) issue (or misunderstanding) down to a small
size, let say we have 2 existing Web Services and that we need collapse into
1 WSDL and then move away from Code-First.  Here are there definitions:

package com.foo;
@WebService(targetNamespace="http://com.foo";)
public interface FooService {
   @WebMethod
   @WebResult(targetNamespace="http://com.foo";)
   String myFooMethod(String x);
}

package com.bar;
@WebService(targetNamespace="http://com.bar";)
public interface BarService {
   @WebMethod
   @WebResult(targetNamespace="http://com.bar";)
   String myBarMethod(String x);
}

After running java2ws on these 2 services, we see that the targetNamespace
for elements and complexTypes  "myBarMethod" and "myBarResponse" are "
http://com.bar";, which is expected (some attributes and other elements
removed for clarity):

<xs:schema xmlns:tns="http://com.bar"; targetNamespace="http://com.bar";
version="1.0">
<xs:element name="myBarMethod" type="tns:myBarMethod"/>
<xs:element name="myBarMethodResponse" type="tns:myBarMethodResponse"/>
<xs:complexType name="myBarMethod">
    <xs:sequence>
      <xs:element minOccurs="0" name="arg0" type="xs:string"/>
    </xs:sequence>
  </xs:complexType>
</xs:schema>


Now, our solution to merge all of these services into one WSDL was to
initially generate the WSDL using java2ws and then migrate our
infrastructure away from java2ws to start using wsdl2java.  The following
solution seemed to be the most efficient to get us there.  We would
basically create a temporary UberService interface that extended FooService
and BarService like so to generate the 1 big WSDL

package com;
@WebService
public interface UberService
  extends FooService , BarService {
}

We then process UberService via java2ws and a UberService.wsdl is generated
and all methods from each service are merged into one WSDL, exactly what we
wanted.  However, we did notice that element/complexType "myBarMethod" ,
"myBarMethodResponse" , "myFooMethod" and "myFooMethodResponse" are now in
the "http://com"; namespace instead of the expected http://com.bar and
http://com.foo namespaces respectively

The 3 WSDL's are attached....

It seems like java2ws in this situation (processing an interface that
extends other interfaces annotated with @WebService) is ignoring the
targetNamespace that is defined for both FooService and BarService.  There
may be a good reason for doing this (specifications, etc) but am not sure if
it is a bug or a feature or PEBKAC :)

Anyone have any thoughts?

Al
<?xml version="1.0" encoding="UTF-8"?>
<wsdl:definitions name="BarServiceService" targetNamespace="http://com.bar"; xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"; xmlns:tns="http://com.bar"; xmlns:xsd="http://www.w3.org/2001/XMLSchema"; xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/";>
  <wsdl:types>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"; xmlns:tns="http://com.bar"; elementFormDefault="unqualified" targetNamespace="http://com.bar"; version="1.0">
<xs:element name="myBarMethod" type="tns:myBarMethod"/>
<xs:element name="myBarMethodResponse" type="tns:myBarMethodResponse"/>
<xs:complexType name="myBarMethod">
    <xs:sequence>
      <xs:element minOccurs="0" name="arg0" type="xs:string"/>
    </xs:sequence>
  </xs:complexType>
<xs:complexType name="myBarMethodResponse">
    <xs:sequence>
      <xs:element form="qualified" minOccurs="0" name="return" type="xs:string"/>
    </xs:sequence>
  </xs:complexType>
</xs:schema>
  </wsdl:types>
  <wsdl:message name="myBarMethodResponse">
    <wsdl:part name="parameters" element="tns:myBarMethodResponse">
    </wsdl:part>
  </wsdl:message>
  <wsdl:message name="myBarMethod">
    <wsdl:part name="parameters" element="tns:myBarMethod">
    </wsdl:part>
  </wsdl:message>
  <wsdl:portType name="BarService">
    <wsdl:operation name="myBarMethod">
      <wsdl:input name="myBarMethod" message="tns:myBarMethod">
    </wsdl:input>
      <wsdl:output name="myBarMethodResponse" message="tns:myBarMethodResponse">
    </wsdl:output>
    </wsdl:operation>
  </wsdl:portType>
  <wsdl:binding name="BarServiceServiceSoapBinding" type="tns:BarService">
    <soap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"/>
    <wsdl:operation name="myBarMethod">
      <soap:operation soapAction="" style="document"/>
      <wsdl:input name="myBarMethod">
        <soap:body use="literal"/>
      </wsdl:input>
      <wsdl:output name="myBarMethodResponse">
        <soap:body use="literal"/>
      </wsdl:output>
    </wsdl:operation>
  </wsdl:binding>
  <wsdl:service name="BarServiceService">
    <wsdl:port name="BarServicePort" binding="tns:BarServiceServiceSoapBinding">
      <soap:address location="http://localhost:9090/BarServicePort"/>
    </wsdl:port>
  </wsdl:service>
</wsdl:definitions>
<?xml version="1.0" encoding="UTF-8"?>
<wsdl:definitions name="FooServiceService" targetNamespace="http://com.foo"; xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"; xmlns:tns="http://com.foo"; xmlns:xsd="http://www.w3.org/2001/XMLSchema"; xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/";>
  <wsdl:types>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"; xmlns:tns="http://com.foo"; elementFormDefault="unqualified" targetNamespace="http://com.foo"; version="1.0">
<xs:element name="myFooMethod" type="tns:myFooMethod"/>
<xs:element name="myFooMethodResponse" type="tns:myFooMethodResponse"/>
<xs:complexType name="myFooMethod">
    <xs:sequence>
      <xs:element minOccurs="0" name="arg0" type="xs:string"/>
    </xs:sequence>
  </xs:complexType>
<xs:complexType name="myFooMethodResponse">
    <xs:sequence>
      <xs:element form="qualified" minOccurs="0" name="return" type="xs:string"/>
    </xs:sequence>
  </xs:complexType>
</xs:schema>
  </wsdl:types>
  <wsdl:message name="myFooMethod">
    <wsdl:part name="parameters" element="tns:myFooMethod">
    </wsdl:part>
  </wsdl:message>
  <wsdl:message name="myFooMethodResponse">
    <wsdl:part name="parameters" element="tns:myFooMethodResponse">
    </wsdl:part>
  </wsdl:message>
  <wsdl:portType name="FooService">
    <wsdl:operation name="myFooMethod">
      <wsdl:input name="myFooMethod" message="tns:myFooMethod">
    </wsdl:input>
      <wsdl:output name="myFooMethodResponse" message="tns:myFooMethodResponse">
    </wsdl:output>
    </wsdl:operation>
  </wsdl:portType>
  <wsdl:binding name="FooServiceServiceSoapBinding" type="tns:FooService">
    <soap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"/>
    <wsdl:operation name="myFooMethod">
      <soap:operation soapAction="" style="document"/>
      <wsdl:input name="myFooMethod">
        <soap:body use="literal"/>
      </wsdl:input>
      <wsdl:output name="myFooMethodResponse">
        <soap:body use="literal"/>
      </wsdl:output>
    </wsdl:operation>
  </wsdl:binding>
  <wsdl:service name="FooServiceService">
    <wsdl:port name="FooServicePort" binding="tns:FooServiceServiceSoapBinding">
      <soap:address location="http://localhost:9090/FooServicePort"/>
    </wsdl:port>
  </wsdl:service>
</wsdl:definitions>
<?xml version="1.0" encoding="UTF-8"?>
<wsdl:definitions name="UberServiceService" targetNamespace="http://com/"; xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"; xmlns:tns="http://com/"; xmlns:xsd="http://www.w3.org/2001/XMLSchema"; xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/";>
  <wsdl:types>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"; xmlns:ns1="http://com.foo"; xmlns:ns2="http://com.bar"; xmlns:tns="http://com/"; elementFormDefault="unqualified" targetNamespace="http://com/"; version="1.0">
<xs:import namespace="http://com.foo"/>
<xs:import namespace="http://com.bar"/>
<xs:element name="myBarMethod" type="tns:myBarMethod"/>
<xs:element name="myBarMethodResponse" type="tns:myBarMethodResponse"/>
<xs:element name="myFooMethod" type="tns:myFooMethod"/>
<xs:element name="myFooMethodResponse" type="tns:myFooMethodResponse"/>
<xs:complexType name="myFooMethod">
    <xs:sequence>
      <xs:element minOccurs="0" name="arg0" type="xs:string"/>
    </xs:sequence>
  </xs:complexType>
<xs:complexType name="myFooMethodResponse">
    <xs:sequence>
      <xs:element minOccurs="0" ref="ns1:return"/>
    </xs:sequence>
  </xs:complexType>
<xs:complexType name="myBarMethod">
    <xs:sequence>
      <xs:element minOccurs="0" name="arg0" type="xs:string"/>
    </xs:sequence>
  </xs:complexType>
<xs:complexType name="myBarMethodResponse">
    <xs:sequence>
      <xs:element minOccurs="0" ref="ns2:return"/>
    </xs:sequence>
  </xs:complexType>
</xs:schema>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"; targetNamespace="http://com.foo"; version="1.0">
<xs:element name="return" type="xs:string"/>
</xs:schema>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"; targetNamespace="http://com.bar"; version="1.0">
<xs:element name="return" type="xs:string"/>
</xs:schema>
  </wsdl:types>
  <wsdl:message name="myFooMethodResponse">
    <wsdl:part name="parameters" element="tns:myFooMethodResponse">
    </wsdl:part>
  </wsdl:message>
  <wsdl:message name="myBarMethod">
    <wsdl:part name="parameters" element="tns:myBarMethod">
    </wsdl:part>
  </wsdl:message>
  <wsdl:message name="myFooMethod">
    <wsdl:part name="parameters" element="tns:myFooMethod">
    </wsdl:part>
  </wsdl:message>
  <wsdl:message name="myBarMethodResponse">
    <wsdl:part name="parameters" element="tns:myBarMethodResponse">
    </wsdl:part>
  </wsdl:message>
  <wsdl:portType name="UberService">
    <wsdl:operation name="myFooMethod">
      <wsdl:input name="myFooMethod" message="tns:myFooMethod">
    </wsdl:input>
      <wsdl:output name="myFooMethodResponse" message="tns:myFooMethodResponse">
    </wsdl:output>
    </wsdl:operation>
    <wsdl:operation name="myBarMethod">
      <wsdl:input name="myBarMethod" message="tns:myBarMethod">
    </wsdl:input>
      <wsdl:output name="myBarMethodResponse" message="tns:myBarMethodResponse">
    </wsdl:output>
    </wsdl:operation>
  </wsdl:portType>
  <wsdl:binding name="UberServiceServiceSoapBinding" type="tns:UberService">
    <soap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"/>
    <wsdl:operation name="myFooMethod">
      <soap:operation soapAction="" style="document"/>
      <wsdl:input name="myFooMethod">
        <soap:body use="literal"/>
      </wsdl:input>
      <wsdl:output name="myFooMethodResponse">
        <soap:body use="literal"/>
      </wsdl:output>
    </wsdl:operation>
    <wsdl:operation name="myBarMethod">
      <soap:operation soapAction="" style="document"/>
      <wsdl:input name="myBarMethod">
        <soap:body use="literal"/>
      </wsdl:input>
      <wsdl:output name="myBarMethodResponse">
        <soap:body use="literal"/>
      </wsdl:output>
    </wsdl:operation>
  </wsdl:binding>
  <wsdl:service name="UberServiceService">
    <wsdl:port name="UberServicePort" binding="tns:UberServiceServiceSoapBinding">
      <soap:address location="http://localhost:9090/UberServicePort"/>
    </wsdl:port>
  </wsdl:service>
</wsdl:definitions>

Reply via email to