You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cxf.apache.org by timis <ba...@mail.ru> on 2012/11/01 09:48:29 UTC

@WebParam(header = true) and it's place in generated SEI.

Hi guys,
I've found a feature or bug during java ->wsdl -> java process. If one of
parameters is marked as @WebParam(header = true) it will be last parameter
in generated SEI on a client side.
There is an example of it. (apache cxf 2.6.2)
WebService

package com.test.foo;

import javax.jws.WebMethod;
import javax.jws.WebParam;
import javax.jws.WebService;


@WebService(
		serviceName = "FooService",
		name = "Foo"
)
public class FooWS {

	@WebMethod
	public Foo getFoo(
			@WebParam(header = true, name = "context") String context,
			@WebParam(name = "arg") String arg
	) {
		return new Foo("hello");
	}
}

then java ->wsdl 
java2ws.bat -wsdl -cp . com.test.foo.FooWS

<?xml version="1.0" encoding="UTF-8"?>
<wsdl:definitions name="FooService" targetNamespace="http://foo.test.com/"
xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
xmlns:tns="http://foo.test.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:tns="http://foo.test.com/" attributeFormDefault="unqualified"
elementFormDefault="unqualified" targetNamespace="http://foo.test.com/">
<xs:element name="getFoo" type="tns:getFoo"/>
<xs:element name="getFooResponse" type="tns:getFooResponse"/>
<xs:complexType name="getFoo">
<xs:sequence>
<xs:element minOccurs="0" name="arg" type="xs:string"/>
</xs:sequence>
</xs:complexType>
<xs:complexType name="getFooResponse">
<xs:sequence>
<xs:element minOccurs="0" name="return" type="tns:foo"/>
</xs:sequence>
</xs:complexType>
<xs:complexType name="foo">
<xs:sequence>
<xs:element minOccurs="0" name="str" type="xs:string"/>
</xs:sequence>
</xs:complexType>
<xs:element name="context" nillable="true" type="xs:string"/>
</xs:schema>
  </wsdl:types>
  <wsdl:message name="getFooResponse">
    <wsdl:part name="parameters" element="tns:getFooResponse">
    </wsdl:part>
  </wsdl:message>
  <wsdl:message name="getFoo">
    <wsdl:part name="parameters" element="tns:getFoo">
    </wsdl:part>
    <wsdl:part name="context" element="tns:context">
    </wsdl:part>
  </wsdl:message>
  <wsdl:portType name="Foo">
    <wsdl:operation name="getFoo">
      <wsdl:input name="getFoo" message="tns:getFoo">
    </wsdl:input>
      <wsdl:output name="getFooResponse" message="tns:getFooResponse">
    </wsdl:output>
    </wsdl:operation>
  </wsdl:portType>
  <wsdl:binding name="FooServiceSoapBinding" type="tns:Foo">
    <soap:binding style="document"
transport="http://schemas.xmlsoap.org/soap/http"/>
    <wsdl:operation name="getFoo">
      <soap:operation soapAction="" style="document"/>
      <wsdl:input name="getFoo">
        <soap:header message="tns:getFoo" part="context" use="literal">
        </soap:header>
        <soap:body parts="parameters" use="literal"/>
      </wsdl:input>
      <wsdl:output name="getFooResponse">
        <soap:body use="literal"/>
      </wsdl:output>
    </wsdl:operation>
  </wsdl:binding>
  <wsdl:service name="FooService">
    <wsdl:port name="FooPort" binding="tns:FooServiceSoapBinding">
      <soap:address location="http://localhost:9090/FooPort"/>
    </wsdl:port>
  </wsdl:service>
</wsdl:definitions>

you can see that order of parameters have changed  

  <wsdl:message name="getFoo">
    <wsdl:part name="parameters" element="tns:getFoo">
    </wsdl:part>
    <wsdl:part name="context" element="tns:context">
    </wsdl:part>
  </wsdl:message>

then java → wsdl
wsdl2java.bat FooService.wsdl

now SEI looks like

package com.test.foo;

import javax.jws.WebMethod;
import javax.jws.WebParam;
import javax.jws.WebResult;
import javax.jws.WebService;
import javax.jws.soap.SOAPBinding;
import javax.xml.bind.annotation.XmlSeeAlso;

/**
 * This class was generated by Apache CXF 2.6.2
 * 2012-11-01T12:09:35.926+04:00
 * Generated source version: 2.6.2
 * 
 */
@WebService(targetNamespace = "http://foo.test.com/", name = "Foo")
@XmlSeeAlso({ObjectFactory.class})
@SOAPBinding(parameterStyle = SOAPBinding.ParameterStyle.BARE)
public interface Foo {

    @WebResult(name = "getFooResponse", targetNamespace =
"http://foo.test.com/", partName = "parameters")
    @WebMethod
    public GetFooResponse getFoo(
        @WebParam(partName = "parameters", name = "getFoo", targetNamespace
= "http://foo.test.com/")
        GetFoo parameters,
        @WebParam(partName = "context", name = "context", targetNamespace =
"http://foo.test.com/", header = true)
        java.lang.String context
    );
}
you can see that order of parameters have changed.
Is it a bug or feature ? How can I manage order of parameters? Are there any
workarounds?



--
View this message in context: http://cxf.547215.n5.nabble.com/WebParam-header-true-and-it-s-place-in-generated-SEI-tp5717680.html
Sent from the cxf-user mailing list archive at Nabble.com.

Re: @WebParam(header = true) and it's place in generated SEI.

Posted by Daniel Kulp <dk...@apache.org>.
 
This is part of the wrapped doc/lit standard.   That requires the first part in the message in the wsdl to represent the parameters that are passed to the method.    Headers are stuck after that.

Dan


On Nov 1, 2012, at 4:48 AM, timis <ba...@mail.ru> wrote:

> Hi guys,
> I've found a feature or bug during java ->wsdl -> java process. If one of
> parameters is marked as @WebParam(header = true) it will be last parameter
> in generated SEI on a client side.
> There is an example of it. (apache cxf 2.6.2)
> WebService
> 
> package com.test.foo;
> 
> import javax.jws.WebMethod;
> import javax.jws.WebParam;
> import javax.jws.WebService;
> 
> 
> @WebService(
> 		serviceName = "FooService",
> 		name = "Foo"
> )
> public class FooWS {
> 
> 	@WebMethod
> 	public Foo getFoo(
> 			@WebParam(header = true, name = "context") String context,
> 			@WebParam(name = "arg") String arg
> 	) {
> 		return new Foo("hello");
> 	}
> }
> 
> then java ->wsdl 
> java2ws.bat -wsdl -cp . com.test.foo.FooWS
> 
> <?xml version="1.0" encoding="UTF-8"?>
> <wsdl:definitions name="FooService" targetNamespace="http://foo.test.com/"
> xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
> xmlns:tns="http://foo.test.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:tns="http://foo.test.com/" attributeFormDefault="unqualified"
> elementFormDefault="unqualified" targetNamespace="http://foo.test.com/">
> <xs:element name="getFoo" type="tns:getFoo"/>
> <xs:element name="getFooResponse" type="tns:getFooResponse"/>
> <xs:complexType name="getFoo">
> <xs:sequence>
> <xs:element minOccurs="0" name="arg" type="xs:string"/>
> </xs:sequence>
> </xs:complexType>
> <xs:complexType name="getFooResponse">
> <xs:sequence>
> <xs:element minOccurs="0" name="return" type="tns:foo"/>
> </xs:sequence>
> </xs:complexType>
> <xs:complexType name="foo">
> <xs:sequence>
> <xs:element minOccurs="0" name="str" type="xs:string"/>
> </xs:sequence>
> </xs:complexType>
> <xs:element name="context" nillable="true" type="xs:string"/>
> </xs:schema>
>  </wsdl:types>
>  <wsdl:message name="getFooResponse">
>    <wsdl:part name="parameters" element="tns:getFooResponse">
>    </wsdl:part>
>  </wsdl:message>
>  <wsdl:message name="getFoo">
>    <wsdl:part name="parameters" element="tns:getFoo">
>    </wsdl:part>
>    <wsdl:part name="context" element="tns:context">
>    </wsdl:part>
>  </wsdl:message>
>  <wsdl:portType name="Foo">
>    <wsdl:operation name="getFoo">
>      <wsdl:input name="getFoo" message="tns:getFoo">
>    </wsdl:input>
>      <wsdl:output name="getFooResponse" message="tns:getFooResponse">
>    </wsdl:output>
>    </wsdl:operation>
>  </wsdl:portType>
>  <wsdl:binding name="FooServiceSoapBinding" type="tns:Foo">
>    <soap:binding style="document"
> transport="http://schemas.xmlsoap.org/soap/http"/>
>    <wsdl:operation name="getFoo">
>      <soap:operation soapAction="" style="document"/>
>      <wsdl:input name="getFoo">
>        <soap:header message="tns:getFoo" part="context" use="literal">
>        </soap:header>
>        <soap:body parts="parameters" use="literal"/>
>      </wsdl:input>
>      <wsdl:output name="getFooResponse">
>        <soap:body use="literal"/>
>      </wsdl:output>
>    </wsdl:operation>
>  </wsdl:binding>
>  <wsdl:service name="FooService">
>    <wsdl:port name="FooPort" binding="tns:FooServiceSoapBinding">
>      <soap:address location="http://localhost:9090/FooPort"/>
>    </wsdl:port>
>  </wsdl:service>
> </wsdl:definitions>
> 
> you can see that order of parameters have changed  
> 
>  <wsdl:message name="getFoo">
>    <wsdl:part name="parameters" element="tns:getFoo">
>    </wsdl:part>
>    <wsdl:part name="context" element="tns:context">
>    </wsdl:part>
>  </wsdl:message>
> 
> then java → wsdl
> wsdl2java.bat FooService.wsdl
> 
> now SEI looks like
> 
> package com.test.foo;
> 
> import javax.jws.WebMethod;
> import javax.jws.WebParam;
> import javax.jws.WebResult;
> import javax.jws.WebService;
> import javax.jws.soap.SOAPBinding;
> import javax.xml.bind.annotation.XmlSeeAlso;
> 
> /**
> * This class was generated by Apache CXF 2.6.2
> * 2012-11-01T12:09:35.926+04:00
> * Generated source version: 2.6.2
> * 
> */
> @WebService(targetNamespace = "http://foo.test.com/", name = "Foo")
> @XmlSeeAlso({ObjectFactory.class})
> @SOAPBinding(parameterStyle = SOAPBinding.ParameterStyle.BARE)
> public interface Foo {
> 
>    @WebResult(name = "getFooResponse", targetNamespace =
> "http://foo.test.com/", partName = "parameters")
>    @WebMethod
>    public GetFooResponse getFoo(
>        @WebParam(partName = "parameters", name = "getFoo", targetNamespace
> = "http://foo.test.com/")
>        GetFoo parameters,
>        @WebParam(partName = "context", name = "context", targetNamespace =
> "http://foo.test.com/", header = true)
>        java.lang.String context
>    );
> }
> you can see that order of parameters have changed.
> Is it a bug or feature ? How can I manage order of parameters? Are there any
> workarounds?
> 
> 
> 
> --
> View this message in context: http://cxf.547215.n5.nabble.com/WebParam-header-true-and-it-s-place-in-generated-SEI-tp5717680.html
> Sent from the cxf-user mailing list archive at Nabble.com.

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


Re: @WebParam(header = true) and it's place in generated SEI.

Posted by Glen Mazza <gm...@talend.com>.
I prefer the current Metro/CXF default. Header parameters are usually 
the same and duplicated on all methods in a class.  When my eyes are 
scrolling across a method signature line I like to see the 
method-specific parameters first and ignore the boilerplate header 
fields at the end instead of needing to wade through the latter every 
time before I can get to the unique method-specific stuff I'm interested in.

Glen

On 11/01/2012 08:16 AM, timis wrote:
> Glen,
> Thank you for your quick reply.
> Metro wsdl
>
> <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
>
> <definitions targetNamespace="http://foo.test.com/" name="FooService"
> xmlns="http://schemas.xmlsoap.org/wsdl/"
> xmlns:wsp="http://www.w3.org/ns/ws-policy" xmlns:tns="http://foo.test.com/"
> xmlns:xsd="http://www.w3.org/2001/XMLSchema"
> xmlns:wsp1_2="http://schemas.xmlsoap.org/ws/2004/09/policy"
> xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
> xmlns:wsam="http://www.w3.org/2007/05/addressing/metadata"
> xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd">
>    <types>
>      <xsd:schema>
>        <xsd:import namespace="http://foo.test.com/"
> schemaLocation="FooService_schema1.xsd"/>
>      </xsd:schema>
>    </types>
>    <message name="getFoo">
>      <part name="parameters" element="tns:getFoo"/>
>      <part name="context" element="tns:context"/>
>    </message>
>    <message name="getFooResponse">
>      <part name="result" element="tns:getFooResponse"/>
>    </message>
>    <portType name="Foo">
>      <operation name="getFoo" parameterOrder="parameters context">
>        <input wsam:Action="http://foo.test.com/Foo/getFooRequest"
> message="tns:getFoo"/>
>        <output wsam:Action="http://foo.test.com/Foo/getFooResponse"
> message="tns:getFooResponse"/>
>      </operation>
>    </portType>
>    <binding name="FooPortBinding" type="tns:Foo">
>      <soap:binding transport="http://schemas.xmlsoap.org/soap/http"
> style="document"/>
>      <operation name="getFoo">
>        <soap:operation soapAction=""/>
>        <input>
>          <soap:body use="literal" parts="parameters"/>
>          <soap:header message="tns:getFoo" part="context" use="literal"/>
>        </input>
>        <output>
>          <soap:body use="literal"/>
>        </output>
>      </operation>
>    </binding>
>    <service name="FooService">
>      <port name="FooPort" binding="tns:FooPortBinding">
>        <soap:address location="REPLACE_WITH_ACTUAL_URL"/>
>      </port>
>    </service>
> </definitions>
>
> As you can see order of parameters has changed, but I didn't find anything
> about it in the wsdl specification. I wish I had the same SEI after
> generation from wsdl.
>
>
>
> --
> View this message in context: http://cxf.547215.n5.nabble.com/WebParam-header-true-and-it-s-place-in-generated-SEI-tp5717680p5717689.html
> Sent from the cxf-user mailing list archive at Nabble.com.


-- 
Glen Mazza
Talend Community Coders - coders.talend.com
blog: www.jroller.com/gmazza


Re: @WebParam(header = true) and it's place in generated SEI.

Posted by timis <ba...@mail.ru>.
Glen,
Thank you for your quick reply. 
Metro wsdl

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

<definitions targetNamespace="http://foo.test.com/" name="FooService"
xmlns="http://schemas.xmlsoap.org/wsdl/"
xmlns:wsp="http://www.w3.org/ns/ws-policy" xmlns:tns="http://foo.test.com/"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:wsp1_2="http://schemas.xmlsoap.org/ws/2004/09/policy"
xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
xmlns:wsam="http://www.w3.org/2007/05/addressing/metadata"
xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd">
  <types>
    <xsd:schema>
      <xsd:import namespace="http://foo.test.com/"
schemaLocation="FooService_schema1.xsd"/>
    </xsd:schema>
  </types>
  <message name="getFoo">
    <part name="parameters" element="tns:getFoo"/>
    <part name="context" element="tns:context"/>
  </message>
  <message name="getFooResponse">
    <part name="result" element="tns:getFooResponse"/>
  </message>
  <portType name="Foo">
    <operation name="getFoo" parameterOrder="parameters context">
      <input wsam:Action="http://foo.test.com/Foo/getFooRequest"
message="tns:getFoo"/>
      <output wsam:Action="http://foo.test.com/Foo/getFooResponse"
message="tns:getFooResponse"/>
    </operation>
  </portType>
  <binding name="FooPortBinding" type="tns:Foo">
    <soap:binding transport="http://schemas.xmlsoap.org/soap/http"
style="document"/>
    <operation name="getFoo">
      <soap:operation soapAction=""/>
      <input>
        <soap:body use="literal" parts="parameters"/>
        <soap:header message="tns:getFoo" part="context" use="literal"/>
      </input>
      <output>
        <soap:body use="literal"/>
      </output>
    </operation>
  </binding>
  <service name="FooService">
    <port name="FooPort" binding="tns:FooPortBinding">
      <soap:address location="REPLACE_WITH_ACTUAL_URL"/>
    </port>
  </service>
</definitions>

As you can see order of parameters has changed, but I didn't find anything
about it in the wsdl specification. I wish I had the same SEI after
generation from wsdl.



--
View this message in context: http://cxf.547215.n5.nabble.com/WebParam-header-true-and-it-s-place-in-generated-SEI-tp5717680p5717689.html
Sent from the cxf-user mailing list archive at Nabble.com.

Re: @WebParam(header = true) and it's place in generated SEI.

Posted by Glen Mazza <gm...@talend.com>.
That just might be a CXF convention, to put header arguments at the end 
of parameter list.  Possibly the JAX-WS specification mandates it.  It 
might be interesting to find out what Metro would do (links #3 and #2 
here: http://www.jroller.com/gmazza/entry/blog_article_index); also note 
many WSDLs do not define header information in the wsdl:portType section 
as you're doing below (link #56 from above) -- just placing it 
exclusively in the binding section of the WSDL instead.  But if you're 
starting from Java instead of from WSDL I'm not sure how you can take 
that latter approach.

Glen

On 11/01/2012 04:48 AM, timis wrote:
> Hi guys,
> I've found a feature or bug during java ->wsdl -> java process. If one of
> parameters is marked as @WebParam(header = true) it will be last parameter
> in generated SEI on a client side.
> There is an example of it. (apache cxf 2.6.2)
> WebService
>
> package com.test.foo;
>
> import javax.jws.WebMethod;
> import javax.jws.WebParam;
> import javax.jws.WebService;
>
>
> @WebService(
> 		serviceName = "FooService",
> 		name = "Foo"
> )
> public class FooWS {
>
> 	@WebMethod
> 	public Foo getFoo(
> 			@WebParam(header = true, name = "context") String context,
> 			@WebParam(name = "arg") String arg
> 	) {
> 		return new Foo("hello");
> 	}
> }
>
> then java ->wsdl
> java2ws.bat -wsdl -cp . com.test.foo.FooWS
>
> <?xml version="1.0" encoding="UTF-8"?>
> <wsdl:definitions name="FooService" targetNamespace="http://foo.test.com/"
> xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
> xmlns:tns="http://foo.test.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:tns="http://foo.test.com/" attributeFormDefault="unqualified"
> elementFormDefault="unqualified" targetNamespace="http://foo.test.com/">
> <xs:element name="getFoo" type="tns:getFoo"/>
> <xs:element name="getFooResponse" type="tns:getFooResponse"/>
> <xs:complexType name="getFoo">
> <xs:sequence>
> <xs:element minOccurs="0" name="arg" type="xs:string"/>
> </xs:sequence>
> </xs:complexType>
> <xs:complexType name="getFooResponse">
> <xs:sequence>
> <xs:element minOccurs="0" name="return" type="tns:foo"/>
> </xs:sequence>
> </xs:complexType>
> <xs:complexType name="foo">
> <xs:sequence>
> <xs:element minOccurs="0" name="str" type="xs:string"/>
> </xs:sequence>
> </xs:complexType>
> <xs:element name="context" nillable="true" type="xs:string"/>
> </xs:schema>
>    </wsdl:types>
>    <wsdl:message name="getFooResponse">
>      <wsdl:part name="parameters" element="tns:getFooResponse">
>      </wsdl:part>
>    </wsdl:message>
>    <wsdl:message name="getFoo">
>      <wsdl:part name="parameters" element="tns:getFoo">
>      </wsdl:part>
>      <wsdl:part name="context" element="tns:context">
>      </wsdl:part>
>    </wsdl:message>
>    <wsdl:portType name="Foo">
>      <wsdl:operation name="getFoo">
>        <wsdl:input name="getFoo" message="tns:getFoo">
>      </wsdl:input>
>        <wsdl:output name="getFooResponse" message="tns:getFooResponse">
>      </wsdl:output>
>      </wsdl:operation>
>    </wsdl:portType>
>    <wsdl:binding name="FooServiceSoapBinding" type="tns:Foo">
>      <soap:binding style="document"
> transport="http://schemas.xmlsoap.org/soap/http"/>
>      <wsdl:operation name="getFoo">
>        <soap:operation soapAction="" style="document"/>
>        <wsdl:input name="getFoo">
>          <soap:header message="tns:getFoo" part="context" use="literal">
>          </soap:header>
>          <soap:body parts="parameters" use="literal"/>
>        </wsdl:input>
>        <wsdl:output name="getFooResponse">
>          <soap:body use="literal"/>
>        </wsdl:output>
>      </wsdl:operation>
>    </wsdl:binding>
>    <wsdl:service name="FooService">
>      <wsdl:port name="FooPort" binding="tns:FooServiceSoapBinding">
>        <soap:address location="http://localhost:9090/FooPort"/>
>      </wsdl:port>
>    </wsdl:service>
> </wsdl:definitions>
>
> you can see that order of parameters have changed
>
>    <wsdl:message name="getFoo">
>      <wsdl:part name="parameters" element="tns:getFoo">
>      </wsdl:part>
>      <wsdl:part name="context" element="tns:context">
>      </wsdl:part>
>    </wsdl:message>
>
> then java → wsdl
> wsdl2java.bat FooService.wsdl
>
> now SEI looks like
>
> package com.test.foo;
>
> import javax.jws.WebMethod;
> import javax.jws.WebParam;
> import javax.jws.WebResult;
> import javax.jws.WebService;
> import javax.jws.soap.SOAPBinding;
> import javax.xml.bind.annotation.XmlSeeAlso;
>
> /**
>   * This class was generated by Apache CXF 2.6.2
>   * 2012-11-01T12:09:35.926+04:00
>   * Generated source version: 2.6.2
>   *
>   */
> @WebService(targetNamespace = "http://foo.test.com/", name = "Foo")
> @XmlSeeAlso({ObjectFactory.class})
> @SOAPBinding(parameterStyle = SOAPBinding.ParameterStyle.BARE)
> public interface Foo {
>
>      @WebResult(name = "getFooResponse", targetNamespace =
> "http://foo.test.com/", partName = "parameters")
>      @WebMethod
>      public GetFooResponse getFoo(
>          @WebParam(partName = "parameters", name = "getFoo", targetNamespace
> = "http://foo.test.com/")
>          GetFoo parameters,
>          @WebParam(partName = "context", name = "context", targetNamespace =
> "http://foo.test.com/", header = true)
>          java.lang.String context
>      );
> }
> you can see that order of parameters have changed.
> Is it a bug or feature ? How can I manage order of parameters? Are there any
> workarounds?
>
>
>
> --
> View this message in context: http://cxf.547215.n5.nabble.com/WebParam-header-true-and-it-s-place-in-generated-SEI-tp5717680.html
> Sent from the cxf-user mailing list archive at Nabble.com.


-- 
Glen Mazza
Talend Community Coders - coders.talend.com
blog: www.jroller.com/gmazza