You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cxf.apache.org by Eric Ettes <er...@gmail.com> on 2012/11/09 15:12:12 UTC

Unwanted Holders in generated classes (Java)

Dear all,

I'm currently building a Java application with CXF, and it worked, until I received a new set of WSDL's.

When generating new classes from said WSDL's, my reply methods get an extra parameter 'result':


    @WebResult(name = "rebootReply", targetNamespace = "urn://blueMeasure/box/1/0/", partName = "parameters")
    @Action(input = "/reboot")
    @WebMethod(action = "/reboot")
    public RebootReply reboot(
        @WebParam(partName = "parameters", name = "rebootRequest", targetNamespace = "urn://blueMeasure/box/1/0/")
        RebootRequest parameters,
        @WebParam(partName = "identity", name = "identity", targetNamespace = "urn://blueMeasure/box/1/0/", header = true)
        java.lang.String identity,
        @WebParam(partName = "result", mode = WebParam.Mode.OUT, name = "result", targetNamespace = "urn://blueMeasure/box/1/0/", header = true)
        javax.xml.ws.Holder<Result> result
    );


I've been reading about people using .net with the exact same problem, only opposite. I've tried adding extraargs to my wsdl2java, but that didn't work, so maybe I'm missing something. I'll paste a snippet from the wsdl (only using the reboot part), and my wsdl2java section, perhaps there is something wrong with the wsdl?

WSDL:

<?xml version="1.0" encoding="UTF-8" standalone="no"?>

<wsdl:definitions xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
                  xmlns:soap12="http://schemas.xmlsoap.org/wsdl/soap12/"
                  xmlns:s="http://www.w3.org/2001/XMLSchema"
      			   xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
                  xmlns:wsaw="http://www.w3.org/2006/05/addressing/wsdl"
                  xmlns:wsp="http://schemas.xmlsoap.org/ws/2004/09/policy"
                  xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd"
                  xmlns:jaxws="http://java.sun.com/xml/ns/jaxws"
                  xmlns:tns="urn://blueMeasure/box/1/0/"
                  targetNamespace="urn://blueMeasure/box/1/0/">

	<wsp:Policy wsu:Id="ServicePolicy">
    	<wsp:ExactlyOne>
      		<wsp:All>
      		</wsp:All>
    	</wsp:ExactlyOne>
  	</wsp:Policy>
                    
    <wsdl:types>
    	<s:schema targetNamespace="urn://blueMeasure/box/1/0/">

			<s:simpleType name="rebootType">
				<s:restriction base="s:string">
					<s:enumeration value="soft"/>
					<s:enumeration value="hard"/>
				</s:restriction>
			</s:simpleType>

	      <s:complexType name="rebootRequest">
	        <s:sequence>
				<s:element name="type" type="tns:rebootType" minOccurs="1" maxOccurs="1" />
	        </s:sequence>
	      </s:complexType>

	      <s:complexType name="rebootReply">
	        <s:sequence>
	        </s:sequence>
	      </s:complexType>

	      <s:element name="rebootRequest"           type="tns:rebootRequest" />
	      <s:element name="rebootReply"             type="tns:rebootReply" />
    	
    	</s:schema>
   	</wsdl:types>

	<wsdl:message name="rebootInput">
		<wsdl:part name="parameters" element="tns:rebootRequest" />
	</wsdl:message>

	<wsdl:message name="rebootOutput">
		<wsdl:part name="parameters" element="tns:rebootReply" />
	</wsdl:message>

	<wsdl:portType name="blueMeasure2box">

     <wsdl:operation name="reboot">
       <wsdl:input message="tns:rebootInput" wsaw:Action="/reboot" />
       <wsdl:output message="tns:rebootOutput" />
     </wsdl:operation>

	</wsdl:portType>

     <wsdl:binding name="blueMeasure2boxService" type="tns:blueMeasure2box">
     <wsp:PolicyReference URI="#ServicePolicy" />
     <soap12:binding transport="http://schemas.xmlsoap.org/soap/http" />
	
      <wsdl:operation name="reboot">
        <soap12:operation soapAction="/reboot" style="document" />
        <wsdl:input>
          <soap12:header use="literal" message="tns:requestHeader" part="identity"/>
          <soap12:body use="literal" />
        </wsdl:input>
        <wsdl:output>
          <soap12:header use="literal" message="tns:replyHeader" part="result"/>
          <soap12:body use="literal" />
        </wsdl:output>
      </wsdl:operation>
	
	</wsdl:binding>

  <wsdl:service name="blueMeasure2box">
    <wsdl:port name="blueMeasure2box10" binding="tns:blueMeasure2boxService">
      <soap12:address location="http://localhost/blueMeasure/blueMeasure2box10/" />
    </wsdl:port>
  </wsdl:service>

</wsdl:definitions>

pom.xml / build:
    <build>
        <plugins>
            <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>
                        <configuration>
                            <wsdlOptions>
                                <wsdlOption>
                                    <wsdl>${basedir}/src/main/resources/wsdl/blueMeasure2box.wsdl</wsdl>
                                    <wsdlLocation>classpath:wsdl/blueMeasure2box.wsdl</wsdlLocation>
                                    <packagenames>
                                        <packagename>ohmp.bluemeasure2box</packagename>
                                    </packagenames>
                                    <extraargs>
                                        <extraarg>-verbose</extraarg>
                                        <extraarg>-exsh</extraarg>
                                        <extraarg>true</extraarg>
                                        <extraarg>-bareMethods=reboot</extraarg>
                                    </extraargs>
                                </wsdlOption>
                                <wsdlOption>
                                    <wsdl>${basedir}/src/main/resources/wsdl/blueMeasure2master.wsdl</wsdl>
                                    <wsdlLocation>classpath:wsdl/blueMeasure2master.wsdl</wsdlLocation>
                                    <packagenames>
                                        <packagename>ohmp.bluemeasure2master</packagename>
                                    </packagenames>
                                    <extraargs>
                                        <extraarg>-client</extraarg>
                                        <extraarg>-exsh</extraarg>
                                        <extraarg>true</extraarg>
                                    </extraargs>
                                </wsdlOption>
                            </wsdlOptions>
                        </configuration>
                        <goals>
                            <goal>wsdl2java</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
        </plugins>
    </build>

As you can see, I still have the -bareMethods=reboot as an extraArg, hoping that the reboot method would lack the Holder but that didn't work :-(

Kind regards,
Eric

Re: Unwanted Holders in generated classes (Java)

Posted by Eric Ettes <er...@gmail.com>.
Thanks Dan,

I relocated that part of the message to my reply object and now it behaves exactly how I want it to!

Kind regards,
Eric

On Nov 9, 2012, at 3:40 PM, Daniel Kulp <dk...@apache.org> wrote:

> 
> It's likely due to the "-exsh true" flags and the headers for the response:
> 
>>         <soap12:header use="literal" message="tns:replyHeader" part="result"/>
> 
> 
> To be able to pass the header back to the client, the holder needs to be generated.
> 
> 
> Dan
> 
> 
> 
> On Nov 9, 2012, at 9:12 AM, Eric Ettes <er...@gmail.com> wrote:
> 
>> Dear all,
>> 
>> I'm currently building a Java application with CXF, and it worked, until I received a new set of WSDL's.
>> 
>> When generating new classes from said WSDL's, my reply methods get an extra parameter 'result':
>> 
>> 
>>   @WebResult(name = "rebootReply", targetNamespace = "urn://blueMeasure/box/1/0/", partName = "parameters")
>>   @Action(input = "/reboot")
>>   @WebMethod(action = "/reboot")
>>   public RebootReply reboot(
>>       @WebParam(partName = "parameters", name = "rebootRequest", targetNamespace = "urn://blueMeasure/box/1/0/")
>>       RebootRequest parameters,
>>       @WebParam(partName = "identity", name = "identity", targetNamespace = "urn://blueMeasure/box/1/0/", header = true)
>>       java.lang.String identity,
>>       @WebParam(partName = "result", mode = WebParam.Mode.OUT, name = "result", targetNamespace = "urn://blueMeasure/box/1/0/", header = true)
>>       javax.xml.ws.Holder<Result> result
>>   );
>> 
>> 
>> I've been reading about people using .net with the exact same problem, only opposite. I've tried adding extraargs to my wsdl2java, but that didn't work, so maybe I'm missing something. I'll paste a snippet from the wsdl (only using the reboot part), and my wsdl2java section, perhaps there is something wrong with the wsdl?
>> 
>> WSDL:
>> 
>> <?xml version="1.0" encoding="UTF-8" standalone="no"?>
>> 
>> <wsdl:definitions xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
>>                 xmlns:soap12="http://schemas.xmlsoap.org/wsdl/soap12/"
>>                 xmlns:s="http://www.w3.org/2001/XMLSchema"
>>     			   xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
>>                 xmlns:wsaw="http://www.w3.org/2006/05/addressing/wsdl"
>>                 xmlns:wsp="http://schemas.xmlsoap.org/ws/2004/09/policy"
>>                 xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd"
>>                 xmlns:jaxws="http://java.sun.com/xml/ns/jaxws"
>>                 xmlns:tns="urn://blueMeasure/box/1/0/"
>>                 targetNamespace="urn://blueMeasure/box/1/0/">
>> 
>> 	<wsp:Policy wsu:Id="ServicePolicy">
>>   	<wsp:ExactlyOne>
>>     		<wsp:All>
>>     		</wsp:All>
>>   	</wsp:ExactlyOne>
>> 	</wsp:Policy>
>> 
>>   <wsdl:types>
>>   	<s:schema targetNamespace="urn://blueMeasure/box/1/0/">
>> 
>> 			<s:simpleType name="rebootType">
>> 				<s:restriction base="s:string">
>> 					<s:enumeration value="soft"/>
>> 					<s:enumeration value="hard"/>
>> 				</s:restriction>
>> 			</s:simpleType>
>> 
>> 	      <s:complexType name="rebootRequest">
>> 	        <s:sequence>
>> 				<s:element name="type" type="tns:rebootType" minOccurs="1" maxOccurs="1" />
>> 	        </s:sequence>
>> 	      </s:complexType>
>> 
>> 	      <s:complexType name="rebootReply">
>> 	        <s:sequence>
>> 	        </s:sequence>
>> 	      </s:complexType>
>> 
>> 	      <s:element name="rebootRequest"           type="tns:rebootRequest" />
>> 	      <s:element name="rebootReply"             type="tns:rebootReply" />
>>   	
>>   	</s:schema>
>>  	</wsdl:types>
>> 
>> 	<wsdl:message name="rebootInput">
>> 		<wsdl:part name="parameters" element="tns:rebootRequest" />
>> 	</wsdl:message>
>> 
>> 	<wsdl:message name="rebootOutput">
>> 		<wsdl:part name="parameters" element="tns:rebootReply" />
>> 	</wsdl:message>
>> 
>> 	<wsdl:portType name="blueMeasure2box">
>> 
>>    <wsdl:operation name="reboot">
>>      <wsdl:input message="tns:rebootInput" wsaw:Action="/reboot" />
>>      <wsdl:output message="tns:rebootOutput" />
>>    </wsdl:operation>
>> 
>> 	</wsdl:portType>
>> 
>>    <wsdl:binding name="blueMeasure2boxService" type="tns:blueMeasure2box">
>>    <wsp:PolicyReference URI="#ServicePolicy" />
>>    <soap12:binding transport="http://schemas.xmlsoap.org/soap/http" />
>> 	
>>     <wsdl:operation name="reboot">
>>       <soap12:operation soapAction="/reboot" style="document" />
>>       <wsdl:input>
>>         <soap12:header use="literal" message="tns:requestHeader" part="identity"/>
>>         <soap12:body use="literal" />
>>       </wsdl:input>
>>       <wsdl:output>
>>         <soap12:header use="literal" message="tns:replyHeader" part="result"/>
>>         <soap12:body use="literal" />
>>       </wsdl:output>
>>     </wsdl:operation>
>> 	
>> 	</wsdl:binding>
>> 
>> <wsdl:service name="blueMeasure2box">
>>   <wsdl:port name="blueMeasure2box10" binding="tns:blueMeasure2boxService">
>>     <soap12:address location="http://localhost/blueMeasure/blueMeasure2box10/" />
>>   </wsdl:port>
>> </wsdl:service>
>> 
>> </wsdl:definitions>
>> 
>> pom.xml / build:
>>   <build>
>>       <plugins>
>>           <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>
>>                       <configuration>
>>                           <wsdlOptions>
>>                               <wsdlOption>
>>                                   <wsdl>${basedir}/src/main/resources/wsdl/blueMeasure2box.wsdl</wsdl>
>>                                   <wsdlLocation>classpath:wsdl/blueMeasure2box.wsdl</wsdlLocation>
>>                                   <packagenames>
>>                                       <packagename>ohmp.bluemeasure2box</packagename>
>>                                   </packagenames>
>>                                   <extraargs>
>>                                       <extraarg>-verbose</extraarg>
>>                                       <extraarg>-exsh</extraarg>
>>                                       <extraarg>true</extraarg>
>>                                       <extraarg>-bareMethods=reboot</extraarg>
>>                                   </extraargs>
>>                               </wsdlOption>
>>                               <wsdlOption>
>>                                   <wsdl>${basedir}/src/main/resources/wsdl/blueMeasure2master.wsdl</wsdl>
>>                                   <wsdlLocation>classpath:wsdl/blueMeasure2master.wsdl</wsdlLocation>
>>                                   <packagenames>
>>                                       <packagename>ohmp.bluemeasure2master</packagename>
>>                                   </packagenames>
>>                                   <extraargs>
>>                                       <extraarg>-client</extraarg>
>>                                       <extraarg>-exsh</extraarg>
>>                                       <extraarg>true</extraarg>
>>                                   </extraargs>
>>                               </wsdlOption>
>>                           </wsdlOptions>
>>                       </configuration>
>>                       <goals>
>>                           <goal>wsdl2java</goal>
>>                       </goals>
>>                   </execution>
>>               </executions>
>>           </plugin>
>>       </plugins>
>>   </build>
>> 
>> As you can see, I still have the -bareMethods=reboot as an extraArg, hoping that the reboot method would lack the Holder but that didn't work :-(
>> 
>> Kind regards,
>> Eric
> 
> -- 
> Daniel Kulp
> dkulp@apache.org - http://dankulp.com/blog
> Talend Community Coder - http://coders.talend.com
> 


Re: Unwanted Holders in generated classes (Java)

Posted by Daniel Kulp <dk...@apache.org>.
It's likely due to the "-exsh true" flags and the headers for the response:

>          <soap12:header use="literal" message="tns:replyHeader" part="result"/>


To be able to pass the header back to the client, the holder needs to be generated.


Dan



On Nov 9, 2012, at 9:12 AM, Eric Ettes <er...@gmail.com> wrote:

> Dear all,
> 
> I'm currently building a Java application with CXF, and it worked, until I received a new set of WSDL's.
> 
> When generating new classes from said WSDL's, my reply methods get an extra parameter 'result':
> 
> 
>    @WebResult(name = "rebootReply", targetNamespace = "urn://blueMeasure/box/1/0/", partName = "parameters")
>    @Action(input = "/reboot")
>    @WebMethod(action = "/reboot")
>    public RebootReply reboot(
>        @WebParam(partName = "parameters", name = "rebootRequest", targetNamespace = "urn://blueMeasure/box/1/0/")
>        RebootRequest parameters,
>        @WebParam(partName = "identity", name = "identity", targetNamespace = "urn://blueMeasure/box/1/0/", header = true)
>        java.lang.String identity,
>        @WebParam(partName = "result", mode = WebParam.Mode.OUT, name = "result", targetNamespace = "urn://blueMeasure/box/1/0/", header = true)
>        javax.xml.ws.Holder<Result> result
>    );
> 
> 
> I've been reading about people using .net with the exact same problem, only opposite. I've tried adding extraargs to my wsdl2java, but that didn't work, so maybe I'm missing something. I'll paste a snippet from the wsdl (only using the reboot part), and my wsdl2java section, perhaps there is something wrong with the wsdl?
> 
> WSDL:
> 
> <?xml version="1.0" encoding="UTF-8" standalone="no"?>
> 
> <wsdl:definitions xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
>                  xmlns:soap12="http://schemas.xmlsoap.org/wsdl/soap12/"
>                  xmlns:s="http://www.w3.org/2001/XMLSchema"
>      			   xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
>                  xmlns:wsaw="http://www.w3.org/2006/05/addressing/wsdl"
>                  xmlns:wsp="http://schemas.xmlsoap.org/ws/2004/09/policy"
>                  xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd"
>                  xmlns:jaxws="http://java.sun.com/xml/ns/jaxws"
>                  xmlns:tns="urn://blueMeasure/box/1/0/"
>                  targetNamespace="urn://blueMeasure/box/1/0/">
> 
> 	<wsp:Policy wsu:Id="ServicePolicy">
>    	<wsp:ExactlyOne>
>      		<wsp:All>
>      		</wsp:All>
>    	</wsp:ExactlyOne>
>  	</wsp:Policy>
> 
>    <wsdl:types>
>    	<s:schema targetNamespace="urn://blueMeasure/box/1/0/">
> 
> 			<s:simpleType name="rebootType">
> 				<s:restriction base="s:string">
> 					<s:enumeration value="soft"/>
> 					<s:enumeration value="hard"/>
> 				</s:restriction>
> 			</s:simpleType>
> 
> 	      <s:complexType name="rebootRequest">
> 	        <s:sequence>
> 				<s:element name="type" type="tns:rebootType" minOccurs="1" maxOccurs="1" />
> 	        </s:sequence>
> 	      </s:complexType>
> 
> 	      <s:complexType name="rebootReply">
> 	        <s:sequence>
> 	        </s:sequence>
> 	      </s:complexType>
> 
> 	      <s:element name="rebootRequest"           type="tns:rebootRequest" />
> 	      <s:element name="rebootReply"             type="tns:rebootReply" />
>    	
>    	</s:schema>
>   	</wsdl:types>
> 
> 	<wsdl:message name="rebootInput">
> 		<wsdl:part name="parameters" element="tns:rebootRequest" />
> 	</wsdl:message>
> 
> 	<wsdl:message name="rebootOutput">
> 		<wsdl:part name="parameters" element="tns:rebootReply" />
> 	</wsdl:message>
> 
> 	<wsdl:portType name="blueMeasure2box">
> 
>     <wsdl:operation name="reboot">
>       <wsdl:input message="tns:rebootInput" wsaw:Action="/reboot" />
>       <wsdl:output message="tns:rebootOutput" />
>     </wsdl:operation>
> 
> 	</wsdl:portType>
> 
>     <wsdl:binding name="blueMeasure2boxService" type="tns:blueMeasure2box">
>     <wsp:PolicyReference URI="#ServicePolicy" />
>     <soap12:binding transport="http://schemas.xmlsoap.org/soap/http" />
> 	
>      <wsdl:operation name="reboot">
>        <soap12:operation soapAction="/reboot" style="document" />
>        <wsdl:input>
>          <soap12:header use="literal" message="tns:requestHeader" part="identity"/>
>          <soap12:body use="literal" />
>        </wsdl:input>
>        <wsdl:output>
>          <soap12:header use="literal" message="tns:replyHeader" part="result"/>
>          <soap12:body use="literal" />
>        </wsdl:output>
>      </wsdl:operation>
> 	
> 	</wsdl:binding>
> 
>  <wsdl:service name="blueMeasure2box">
>    <wsdl:port name="blueMeasure2box10" binding="tns:blueMeasure2boxService">
>      <soap12:address location="http://localhost/blueMeasure/blueMeasure2box10/" />
>    </wsdl:port>
>  </wsdl:service>
> 
> </wsdl:definitions>
> 
> pom.xml / build:
>    <build>
>        <plugins>
>            <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>
>                        <configuration>
>                            <wsdlOptions>
>                                <wsdlOption>
>                                    <wsdl>${basedir}/src/main/resources/wsdl/blueMeasure2box.wsdl</wsdl>
>                                    <wsdlLocation>classpath:wsdl/blueMeasure2box.wsdl</wsdlLocation>
>                                    <packagenames>
>                                        <packagename>ohmp.bluemeasure2box</packagename>
>                                    </packagenames>
>                                    <extraargs>
>                                        <extraarg>-verbose</extraarg>
>                                        <extraarg>-exsh</extraarg>
>                                        <extraarg>true</extraarg>
>                                        <extraarg>-bareMethods=reboot</extraarg>
>                                    </extraargs>
>                                </wsdlOption>
>                                <wsdlOption>
>                                    <wsdl>${basedir}/src/main/resources/wsdl/blueMeasure2master.wsdl</wsdl>
>                                    <wsdlLocation>classpath:wsdl/blueMeasure2master.wsdl</wsdlLocation>
>                                    <packagenames>
>                                        <packagename>ohmp.bluemeasure2master</packagename>
>                                    </packagenames>
>                                    <extraargs>
>                                        <extraarg>-client</extraarg>
>                                        <extraarg>-exsh</extraarg>
>                                        <extraarg>true</extraarg>
>                                    </extraargs>
>                                </wsdlOption>
>                            </wsdlOptions>
>                        </configuration>
>                        <goals>
>                            <goal>wsdl2java</goal>
>                        </goals>
>                    </execution>
>                </executions>
>            </plugin>
>        </plugins>
>    </build>
> 
> As you can see, I still have the -bareMethods=reboot as an extraArg, hoping that the reboot method would lack the Holder but that didn't work :-(
> 
> Kind regards,
> Eric

-- 
Daniel Kulp
dkulp@apache.org - http://dankulp.com/blog
Talend Community Coder - http://coders.talend.com