users@jax-ws.java.net

Re: Bare binding causes inability to have multiple web methods

From: Greg Adams <gadams_at_gmail.com>
Date: Wed, 16 Aug 2006 10:58:03 -0700

Actually it was because I had mutliple output message parts, right?
Isn't Microsoft using WS-I BP 1.1 as well? If I make a web service with a
header out parameter as well as the return value in Visual Studio like this:


******************************************************************************************************************************************************

using System;

using System.Web;

using System.Collections;

using System.Web.Services;

using System.Web.Services.Protocols;



public class Header : SoapHeader

{

public string headerValue;

}

/// <summary>

/// Summary description for TestService

/// </summary>

[WebService(Namespace = "http://foo.com/")]

[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]

public class TestService : System.Web.Services.WebService {

public Header header;

public TestService () {

//Uncomment the following line if using designed components

//InitializeComponent();

}

[WebMethod]

[SoapHeader("header", Direction=SoapHeaderDirection.Out)]

public string method1() {

header = new Header();

header.headerValue = "Header Value";

return "method1 Return";

}

}

******************************************************************************************************************************************************

I get WSDL that looks like this:

******************************************************************************************************************************************************

<?xml version="1.0" encoding="utf-8"?>
<wsdl:definitions xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
xmlns:tm="http://microsoft.com/wsdl/mime/textMatching/" xmlns:soapenc="
http://schemas.xmlsoap.org/soap/encoding/" xmlns:mime="
http://schemas.xmlsoap.org/wsdl/mime/" xmlns:tns="http://foo.com/" xmlns:s="
http://www.w3.org/2001/XMLSchema" xmlns:soap12="
http://schemas.xmlsoap.org/wsdl/soap12/" xmlns:http="
http://schemas.xmlsoap.org/wsdl/http/" targetNamespace="http://foo.com/"
xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/">
  <wsdl:types>
    <s:schema elementFormDefault="qualified" targetNamespace="
http://foo.com/">
      <s:element name="method1">
        <s:complexType />
      </s:element>
      <s:element name="method1Response">
        <s:complexType>
          <s:sequence>
            <s:element minOccurs="0" maxOccurs="1" name="method1Result"
type="s:string" />
          </s:sequence>
        </s:complexType>
      </s:element>
      <s:element name="Header" type="tns:Header" />
      <s:complexType name="Header">
        <s:sequence>
          <s:element minOccurs="0" maxOccurs="1" name="headerValue"
type="s:string" />
        </s:sequence>
        <s:anyAttribute />
      </s:complexType>
    </s:schema>
  </wsdl:types>
  <wsdl:message name="method1SoapIn">
    <wsdl:part name="parameters" element="tns:method1" />
  </wsdl:message>
  <wsdl:message name="method1SoapOut">
    <wsdl:part name="parameters" element="tns:method1Response" />
  </wsdl:message>
  <wsdl:message name="method1Header">
    <wsdl:part name="Header" element="tns:Header" />
  </wsdl:message>
  <wsdl:portType name="TestServiceSoap">
    <wsdl:operation name="method1">
      <wsdl:input message="tns:method1SoapIn" />
      <wsdl:output message="tns:method1SoapOut" />
    </wsdl:operation>
  </wsdl:portType>
  <wsdl:binding name="TestServiceSoap" type="tns:TestServiceSoap">
    <soap:binding transport="http://schemas.xmlsoap.org/soap/http" />
    <wsdl:operation name="method1">
      <soap:operation soapAction="http://foo.com/method1" style="document"
/>
      <wsdl:input>
        <soap:body use="literal" />
      </wsdl:input>
      <wsdl:output>
        <soap:body use="literal" />
        <soap:header message="tns:method1Header" part="Header" use="literal"
/>
      </wsdl:output>
    </wsdl:operation>
  </wsdl:binding>
  <wsdl:binding name="TestServiceSoap12" type="tns:TestServiceSoap">
    <soap12:binding transport="http://schemas.xmlsoap.org/soap/http" />
    <wsdl:operation name="method1">
      <soap12:operation soapAction="http://foo.com/method1" style="document"
/>
      <wsdl:input>
        <soap12:body use="literal" />
      </wsdl:input>
      <wsdl:output>
        <soap12:body use="literal" />
        <soap12:header message="tns:method1Header" part="Header"
use="literal" />
      </wsdl:output>
    </wsdl:operation>
  </wsdl:binding>
  <wsdl:service name="TestService">
    <wsdl:port name="TestServiceSoap" binding="tns:TestServiceSoap">
      <soap:address location="
http://localhost:2030/TestService/TestService.asmx" />
    </wsdl:port>
    <wsdl:port name="TestServiceSoap12" binding="tns:TestServiceSoap12">
      <soap12:address location="
http://localhost:2030/TestService/TestService.asmx" />
    </wsdl:port>
  </wsdl:service>
</wsdl:definitions>

******************************************************************************************************************************************************

Visual Studio's proxy generator, wsdl.exe, understands this perfectly. Is
there something about this generated WSDL that is not WS-I BP 1.1 compliant?
How can I annotate my service endpoint java class so that the
JAX-WS-generated WSDL matches the structure above? I'm no expert, but the
WSDL above seems like it's a wrapped parameter style with multiple outputs.
What section of the BP says that this is not allowed?

Greg





On 8/15/06, Vivek Pandey <Vivek.Pandey_at_sun.com> wrote:
>
> Yes, since its BARE style so you would need to provide the wrapper
> element yourself, may be a marker class to clearly distinguish the
> operations.
>
> Well, I guess the workaround due to
> https://jax-ws.dev.java.net/issues/show_bug.cgi?id=33 should also
> include the fact that operation uniqueness constraint as put by BP 1.1.
> Also, the earlier issue with WRAPPER style was because you had more than
> one part in the input message, there were 2 input parameters in the body.
>
> With the SEI in this issue you can use WRAPPER style and I think it
> would work with .net.
>
> -vivek.
>
>
> Greg Adams wrote:
> > So I need to add a parameter I'm not going to use just so that the
> > runtime can distinguish the operation signatures? I was initially
> > using Wrapped parameterStyle, but that conflicted with a requirement I
> > have for using SOAP headers. The workaround suggested here:
> > http://forums.java.net/jive/thread.jspa?threadID=17469&tstart=15
> > <http://forums.java.net/jive/thread.jspa?threadID=17469&tstart=15> was
> > to use the Bare parameterStyle, but that appears to have problems with
> > duplicate operation signatures, so it seems that workaround doesn't
> > really work.
> >
> > On 8/15/06, *Vivek Pandey* <Vivek.Pandey_at_sun.com
> > <mailto:Vivek.Pandey_at_sun.com>> wrote:
> >
> > The failure is because both the operations in the portType have no
> > input
> > parts, this results in empty SOAP body - <soap:Body/>. This causes
> > non-uniqueness of the message signature on the wire.JAXWS complies
> > with
> > BP requirement on uniqueness of operation signature in a
> > portType[1] and
> > does method dispatching on the server side based on the input
> > message or
> > Body tag.
> >
> > Here in this wsdl both method1 and method2 have no input
> > parameters and
> > because its BARE style so there is no input part in the wsdl message
> >
> > *public* String method1() {...}
> >
> >
> > *public* String method2() {...}
> >
> >
> > <message name="method1"></message>
> >
> >
> > <message name="method2"></message>
> >
> >
> > What you need to do is that declare a parameter in these methods,
> for
> > example,
> >
> > public String method1(int foo) {
> > return "method1 return";
> > }
> >
> > and the corresponding generated wsdl will be:
> >
> > <message name="method1">
> > <part name="method1" element="tns:method1"/>
> > </message>
> >
> > ...
> >
> > <xs:element name="method1" type="xs:int"/>
> >
> >
> > This should fix your problem.
> >
> > -vivek.
> > [1]http://www.ws-
> > i.org/Profiles/BasicProfile-1.1.html#Operation_Signatures
> > <http://i.org/Profiles/BasicProfile-1.1.html#Operation_Signatures>
> >
> > Greg Adams wrote:
> > > I'm cross-posting this from the JAX-WS/JAXB discussion forums.
> > >
> > > Here's my java class:
> > >
> > > *package* com.foo;
> > >
> > > *import* javax.jws.WebMethod;
> > > *import* javax.jws.WebService
> > > ;
> > > *import* javax.jws.soap.SOAPBinding;
> > >
> > > @WebService(targetNamespace = " http://foo.com", name = "Test"
> > > )
> > > @SOAPBinding(parameterStyle = SOAPBinding.ParameterStyle.BARE)
> > > *public* *class* TestEndPoint {
> > >
> > >
> > > *public* String method1() {
> > > *return* "method1 return";
> > > }
> > >
> > >
> > >
> > > *public* String method2() {
> > > *return* "method2 return";
> > > }
> > > }
> > >
> > >
> > >
> > >
> > >
> > >
> > > My client (a .Net client using wsdl.exe generated proxies) calls
> > > method1, then method2, but method2 gets called twice.
> > >
> > > I tried adding @WebMethod(operationName="method1",
> > action="method1")
> > > to method1 and @WebMethod(operationName="method2",
> action="method2")
> > > to the methods, but that made no difference.
> > >
> > > Here's the wsdl without the @WebMethod annotations:
> > >
> > >
> > > <?xml version="1.0" encoding="UTF-8"?><definitions xmlns:tns=
> > > "http://foo.com" xmlns"0" src="images/emoticons/love.gif" alt=":x"
> > > >sd="http://www.w3.org/2001/XMLSchema"
> > xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/
> > > < http://schemas.xmlsoap.org/wsdl/soap/>"
> > xmlns="http://schemas.xmlsoap.org/wsdl/" targetNamespace="
> > http://foo.com
> > > " name="TestEndPointService">
> > > <types>
> > > <xsd:schema>
> > > <xsd:*import* namespace="
> > > http://foo.com <http://foo.com>"
> > schemaLocation="http://localhost:8080/jaxWsTest2/services/Test?xsd=1
> "></xsd:import>
> > >
> > > </xsd:schema>
> > > </types>
> > > <message name="method1"></message>
> > > <message name="method1Response">
> > > <part element=
> > > "tns:method1Response" name="method1Response"></part>
> > > </message>
> > > <message name="method2"></message>
> > >
> > > <message name="method2Response">
> > > <part element="tns:method2Response"
> > name="method2Response"></part>
> > >
> > > </message>
> > > <portType name="Test">
> > > <operation name="method1">
> > > <input message="tns:method1"
> > > ></input>
> > > <output message="tns:method1Response"></output>
> > > </operation>
> > > <operation name="method2"
> > > >
> > > <input message="tns:method2"></input>
> > > <output message="tns:method2Response"></output>
> > > </operation>
> > >
> > > </portType>
> > > <binding type="tns:Test" name="TestPortBinding">
> > > <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 use="literal"></soap:body>
> > > </output>
> > > </operation>
> > > <operation name=
> > > "method2">
> > > <soap:operation soapAction=""></soap:operation>
> > > <input>
> > > <soap:body use=
> > > "literal"></soap:body>
> > > </input>
> > > <output>
> > > <soap:body use="literal"></soap:body>
> > > </output>
> > >
> > > </operation>
> > > </binding>
> > > <service name="TestEndPointService">
> > > <port binding="tns:TestPortBinding" name=
> > > "TestPort">
> > > <soap:address
> > location="http://localhost:8080/jaxWsTest2/services/Test
> > <http://localhost:8080/jaxWsTest2/services/Test>"></soap:address>
> > >
> > > </port>
> > > </service>
> > > </definitions>
> > >
> > >
> > >
> > >
> > >
> > >
> > > Any ideas?
> >
> >
> ---------------------------------------------------------------------
> > To unsubscribe, e-mail: users-unsubscribe_at_jax-ws.dev.java.net
> > <mailto:users-unsubscribe_at_jax-ws.dev.java.net>
> > For additional commands, e-mail: users-help_at_jax-ws.dev.java.net
> > <mailto:users-help_at_jax-ws.dev.java.net>
> >
> >
>
> ---------------------------------------------------------------------
> 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
>
>