users@jax-ws.java.net

Re: header out WebParam causing WebResult annotation to be ignored

From: Greg Adams <gadams_at_gmail.com>
Date: Sat, 12 Aug 2006 00:15:54 -0700

Adding a @SOAPBinding(parameterStyle=SOAPBinding.ParameterStyle.BARE)
annotation fixed the problem for me. Thanks.

I've opened an issue. Here's the URL for anyone interested.

https://jax-ws.dev.java.net/issues/show_bug.cgi?id=33

--Greg


On 8/11/06, Greg Adams <gadams_at_gmail.com> wrote:
>
> A little more research:
>
> http://msdn.microsoft.com/msdnmag/issues/02/12/XMLFiles/
>
> The article linked above reveals that wsdl.exe relies on some special
> behavior of message parts named "parameters". When wsdl.exe sees a message
> part named "parameters", it doesn't create a wrapper class. It seems that in
> the case where wsdl.exe is to be used to generate clients for web
> services, simple return types (non-Objects) should get a message part name
> of "parameters".
>
> Also, I'm finding that once I rename the message part from "result" to
> "parameters", this creates a problem with the wsdl:portTypes operation
> element's parameterOrder attribute. The parameterOrder is originally
> "parameters header", since my parameter's message part name is "parameters"
> and the header's part name is "header". Once I rename the message part of
> the result to parameters, I have 2 messages in the operation called
> "parameters". This causes wsdl.exe to generate C# code that looks like
> this:
>
> [System.Web.Services.Protocols.
> SoapHeaderAttribute("headerValue", Direction=System.Web.Services.Protocols.
> SoapHeaderDirection.Out)]
>
> [System.Web.Services.Protocols.
> SoapDocumentMethodAttribute("", RequestNamespace= "http://foo.com/",
> ResponseNamespace="http://foo.com/" , Use=System.Web.Services.Description.
> SoapBindingUse.Literal, ParameterStyle=System.Web.Services.Protocols.SoapParameterStyle.Wrapped)]
>
>
> public void method1([System.Xml.Serialization.XmlElementAttribute (Form=
> System.Xml.Schema.XmlSchemaForm.Unqualified)] out string parameters) {
>
> object[] results = this.Invoke("method1" , new object[0]);
>
> parameters = ((
> string)(results[0]));
>
> }
>
> If I remove the parameterOrder attribute completely, this seems to solve
> the problem, generating C# code that looks like this:
>
>
> [System.Web.Services.Protocols.
> SoapHeaderAttribute("headerValue", Direction=System.Web.Services.Protocols.
> SoapHeaderDirection.Out)]
>
> [System.Web.Services.Protocols.
> SoapDocumentMethodAttribute("", RequestNamespace= "http://foo.com/",
> ResponseNamespace="http://foo.com/" , Use=System.Web.Services.Description.
> SoapBindingUse.Literal, ParameterStyle=System.Web.Services.Protocols.SoapParameterStyle.Wrapped)]
>
>
> [
> return: System.Xml.Serialization.XmlElementAttribute("parameters" , Form=
> System.Xml.Schema.XmlSchemaForm.Unqualified)]
>
> public string method1() {
>
> object[] results = this.Invoke("method1" , new object[0]);
>
> return ((string)(results[0]));
>
> }
>
> So basically to doctor up the wsdl generated by JAX-WS to work with
> wsdl.exe I have to do 2 things
> 1. Rename the "result" message part to "parameters"
> 2. Remove the parameterOrder attribute from the portType's operation
> element.
>
> Is there any way I can achieve these 2 things using annotations?
>
> Greg
>
>
>
>
> On 8/11/06, Greg Adams <gadams_at_gmail.com> wrote:
> >
> > What you're suggesting causes the message part I intend to be in the
> > header to be named "parameters", but the response value is still "result".
> > Wsdl.exe still generates nasty wrappers for the response and method
> > parameters. I need the method return (WebResult) message part to be named
> > "parameters" instead of the default, "result". That's why I'm using
> > @WebResult(name="parameters"), which works without @WebParam(...,
> > header=true), but doesn't work with it.
> >
> > I noticed that the @WebResukt(name="parameters") causes the
> > apt-generated com.foo.jaxws.Method1Response to include an
> > @XmlElement(name="parameters") on the _result member. This happens with or
> > without the @WebParam(..., header=true). It appears that it's not a problem
> > with apt, it's a runtime problem with JAX-WS that causes the @XmlElement
> > annotation in Method1Response to be ignored when there's a header param.
> >
> >
> > On 8/11/06, Doug Kohlert <Doug.Kohlert_at_sun.com > wrote:
> > >
> > > I am not sure this will work, but try: WebParam(name="paramters",
> > > header=true ...)
> > >
> > > Greg Adams wrote:
> > >
> > > > I'm trying to use a header out param in my web service, which must
> > > be
> > > > used with a .Net client. For some reason (don't ask me why), the
> > > > wsdl.exe web service client proxy generator shipped with Visual
> > > Studio
> > > > 2005 really wants the message part for the result in the response
> > > > named "parameters" when using a header out param as well. JAX-WS
> > > > defaults to naming the message part "result", which causes wsdl.exeto
> > > > generate wrapper objects for the response and parameters. Anyways, I
> > > > tried to work around .Net by using this:
> > > >
> > > >package com.foo;
> > > >
> > > >import
> > > > javax.jws.WebParam;
> > > >import javax.jws.WebResult;
> > > >import javax.jws.WebService;
> > > >import javax.xml.ws.Holder;
> > > >
> > > >
> > > >@WebService(serviceName="TestService")
> > > >public class TestEndPoint {
> > > >
> > > > @WebResult(name=
> > > >"parameters")
> > > > public String method1(@WebParam(mode=WebParam.Mode.OUT,
> > > header=true) Holder<Header> header)
> > > >{
> > > > header.value = new Header();
> > > > header.value.setHeaderValue("Header Value");
> > > > return
> > > >"method1 Return";
> > > > }
> > > >}
> > > >
> > > >
> > > >
> > > >
> > > >
> > > > but it appears that when using the WebParam annotation with
> > > > header=true, the WebResult annotation gets ignored. If I remove the
> > > > header=true from the WebParam annotation, the message part is called
> > > > "parameters", but with header=true, the message part is called
> > > "result":
> > > >
> > > ><?xml version="1.0" encoding="UTF-8"?>
> > > ><definitions xmlns: tns="http://foo.com/
> > > > <http://foo.com/ >" xmlns: xsd=" http://www.w3.org/2001/XMLSchema"
> > > >xmlns: soap="
> > > >http://schemas.xmlsoap.org/wsdl/soap/ " xmlns="
> > > http://schemas.xmlsoap.org/wsdl/"
> > > >targetNamespace="
> > > > http://foo.com/" name="TestService">
> > > >
> > > > <types>
> > > > <xsd:schema>
> > > > <xsd:import
> > > > namespace=" http://foo.com/" schemaLocation="http://localhost:8080/jaxWsTest/services/Test?xsd=1
> > > > <http://localhost:8080/jaxWsTest/services/Test?xsd=1>"></xsd:import>
> > >
> > > > </xsd:schema>
> > > > </types>
> > > > <message name="method1">
> > > > <part element="tns:method1"
> > > > name="parameters"></part>
> > > > </message>
> > > > <message name="method1Response">
> > > > <part element=
> > > >"tns:method1Response" name="result"></part>
> > > > <part element="tns:arg0" name="arg0"
> > > >></part>
> > > > </message>
> > > > <portType name="TestEndPoint">
> > > > <operation parameterOrder="parameters arg0" name=
> > > >"method1">
> > > > <input message="tns:method1"></input>
> > > > <output message="tns:method1Response"></output>
> > > >
> > > > </operation>
> > > > </portType>
> > > > <binding type="tns:TestEndPoint" name="TestEndPointPortBinding">
> > > > <soap:binding style=
> > > >"document" transport="http://schemas.xmlsoap.org/soap/http
> > > "></soap:binding>
> > > > <operation name=
> > > >"method1">
> > > > <soap:operation soapAction=""></soap:operation>
> > > > <input>
> > > > <soap:body use=
> > > >"literal"></soap:body>
> > > > </input>
> > > > <output>
> > > > <soap:body parts="result" use="literal"></soap:body>
> > > >
> > > > <soap:header part="arg0" message="tns:method1Response"
> > > use="literal"></soap:header>
> > > > </output>
> > > >
> > > > </operation>
> > > > </binding>
> > > > <service name="TestService">
> > > > <port binding="tns:TestEndPointPortBinding" name=
> > > >"TestEndPointPort">
> > > > <soap:address location="http://localhost:8080/jaxWsTest/services/Test
> > > "></soap:address>
> > > >
> > > > </port>
> > > > </service>
> > > ></definitions>
> > > >
> > > >
> > > >
> > > >
> > > >
> > > >
> > > > Any ideas?
> > > >
> > > > Greg
> > >
> > > ---------------------------------------------------------------------
> > > To unsubscribe, e-mail: users-unsubscribe_at_jax-ws.dev.java.net
> > > For additional commands, e-mail: users-help_at_jax-ws.dev.java.net
> > >
> > >
> >
>