Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > ASP .Net Web Services > .net client + Axis 1.1 server + wrapped param: null result

Reply
Thread Tools

.net client + Axis 1.1 server + wrapped param: null result

 
 
Zihong Lu
Guest
Posts: n/a
 
      06-18-2004
I have used the following settings in our web services:

.net framework 1.1 web services client
Axis 1.1 server (in wsdd file, set style="wrapped")

Using axis client calls the server, it works fine. However, .net
client always returns null, even though the soap message has the
result, for example, for the simple function

string getSession(string username, string password);

The SOAP messages in the response seems to be normal, as shown in this
request/response message:

====== Request ======
<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"
xmlnssi="http://www.w3.org/2001/XMLSchema-instance"
xmlnssd="http://www.w3.org/2001/XMLSchema">
<soap:Body>
<getSession xmlns="urn:myname.com">
<username xmlns="">admin</username>
<password xmlns="" />
</getSession>
</soap:Body>
</soap:Envelope>

====== Response ======
287
<?xml version="1.0" encoding="utf-8"?>
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
xmlnssd="http://www.w3.org/2001/XMLSchema"
xmlnssi="http://www.w3.org/2001/XMLSchema-instance">
<soapenv:Header>
<ns1:sessionID soapenv:actor="http://schemas.xmlsoap.org/soap/actor/next"
soapenv:mustUnderstand="0"
xmlns:ns1="http://xml.apache.org/axis/session">
7413200230928429396
</ns1:sessionID>
</soapenv:Header>
<soapenv:Body>
<getSessionResponse xmlns="urn:myname.com">
<getSessionReturn>7413200230928429396</getSessionReturn>
</getSessionResponse>
</soapenv:Body>
</soapenv:Envelope>
0


No, I don't know why there is a 287 before <?xml> tag and a 0 at the
end of the response message. This may have something to do with the
response HTTP header

Transfer-Encoding: chunked

in responding to the .net request HTTP header of "Connection:
Keep-Alive".

The session ID in SOAP header doesn't seem matter, since I tested the
call with and without the session ID header. I have serached this
group for almost a day, the closest I have found is this link:

http://groups.google.com/groups?selm...ing.google.com

However, it was talking about serializing complex type there. Can
someone plese help?


-Zihong
 
Reply With Quote
 
 
 
 
Dino Chiesa [Microsoft]
Guest
Posts: n/a
 
      06-18-2004
you showed the request and response - I guess that would be a request from
..NET to AXIS and a response from AXIS to .NET.
Can I see the WSDL? or failing that, the client-side proxy generated by
wsdl.exe ??

I am betting it is an xml namespace issue.

-D

"Zihong Lu" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed) om...
> I have used the following settings in our web services:
>
> .net framework 1.1 web services client
> Axis 1.1 server (in wsdd file, set style="wrapped")
>
> Using axis client calls the server, it works fine. However, .net
> client always returns null, even though the soap message has the
> result, for example, for the simple function
>
> string getSession(string username, string password);
>
> The SOAP messages in the response seems to be normal, as shown in this
> request/response message:
>
> ====== Request ======
> <?xml version="1.0" encoding="utf-8"?>
> <soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"
> xmlnssi="http://www.w3.org/2001/XMLSchema-instance"
> xmlnssd="http://www.w3.org/2001/XMLSchema">
> <soap:Body>
> <getSession xmlns="urn:myname.com">
> <username xmlns="">admin</username>
> <password xmlns="" />
> </getSession>
> </soap:Body>
> </soap:Envelope>
>
> ====== Response ======
> 287
> <?xml version="1.0" encoding="utf-8"?>
> <soapenv:Envelope

xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
> xmlnssd="http://www.w3.org/2001/XMLSchema"
> xmlnssi="http://www.w3.org/2001/XMLSchema-instance">
> <soapenv:Header>
> <ns1:sessionID

soapenv:actor="http://schemas.xmlsoap.org/soap/actor/next"
> soapenv:mustUnderstand="0"
> xmlns:ns1="http://xml.apache.org/axis/session">
> 7413200230928429396
> </ns1:sessionID>
> </soapenv:Header>
> <soapenv:Body>
> <getSessionResponse xmlns="urn:myname.com">
> <getSessionReturn>7413200230928429396</getSessionReturn>
> </getSessionResponse>
> </soapenv:Body>
> </soapenv:Envelope>
> 0
>
>
> No, I don't know why there is a 287 before <?xml> tag and a 0 at the
> end of the response message. This may have something to do with the
> response HTTP header
>
> Transfer-Encoding: chunked
>
> in responding to the .net request HTTP header of "Connection:
> Keep-Alive".
>
> The session ID in SOAP header doesn't seem matter, since I tested the
> call with and without the session ID header. I have serached this
> group for almost a day, the closest I have found is this link:
>
>

http://groups.google.com/groups?selm...ing.google.com
>
> However, it was talking about serializing complex type there. Can
> someone plese help?
>
>
> -Zihong



 
Reply With Quote
 
 
 
 
Zihong Lu
Guest
Posts: n/a
 
      06-18-2004
Dino,

Thank you for looking into this. Yes the request/response messages are
..net->axis (request) and axis->.net(response).

Here is the WSDL that I use (Note that I commented out the
<wsdlsoap:header message="impl:soapHeader" part="sessionID" use="literal"/>
for getSession(),
because it is another issue that causing .net confused, it does not know
what "xsd:long" is.)
==================================
<?xml version="1.0" encoding="UTF-8" ?>
<wsdl:definitions targetNamespace="urn:myname.com"
xmlns="http://schemas.xmlsoap.org/wsdl/"
xmlns:apachesoap="http://xml.apache.org/xml-soap"
xmlns:impl="urn:myname.com"
xmlns:intf="urn:myname.com"
xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/"
xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
xmlns:wsdlsoap="http://schemas.xmlsoap.org/wsdl/soap/"
xmlnssd="http://www.w3.org/2001/XMLSchema"
xmlns:session="http://xml.apache.org/axis/session">

<documentation />

<wsdl:types>

<schema targetNamespace="http://xml.apache.org/axis/session"
xmlns="http://www.w3.org/2001/XMLSchema">
<simpleType name="session">
<restriction base="xsd:long"/>
</simpleType>
<element name="sessionID" type="session:session"/>
</schema>

<schema targetNamespace="urn:myname.com"
xmlns="http://www.w3.org/2001/XMLSchema">


<element name="getSession">
<complexType>
<sequence>
<element name="username" type="xsd:string" />
<element name="password" type="xsd:string" />
</sequence>
</complexType>
</element>

<element name="getSessionResponse">
<complexType>
<sequence>
<element name="getSessionReturn" type="xsd:string" />
</sequence>
</complexType>
</element>

<element name="closeSession">
<complexType />
</element>

<element name="closeSessionResponse">
<complexType />
</element>

</schema>
</wsdl:types>

<wsdl:message name="soapHeader">
<wsdlart name="sessionID" element="session:sessionID" />
</wsdl:message>

<wsdl:message name="getSessionRequest">
<wsdlart element="impl:getSession" name="parameters" />
</wsdl:message>

<wsdl:message name="getSessionResponse">
<wsdlart element="impl:getSessionResponse" name="parameters" />
</wsdl:message>

<wsdl:message name="closeSessionRequest">
<wsdlart element="impl:closeSession" name="parameters" />
</wsdl:message>

<wsdl:message name="closeSessionResponse">
<wsdlart element="impl:closeSessionResponse" name="parameters" />
</wsdl:message>

<wsdlortType name="MynameService">

<wsdlperation name="getSession" parameterOrder="">
<wsdl:input message="impl:getSessionRequest"
name="getSessionRequest" />
<wsdlutput message="impl:getSessionResponse"
name="getSessionResponse" />
</wsdlperation>

<wsdlperation name="closeSession">
<wsdl:input message="impl:closeSessionRequest"
name="closeSessionRequest" />
<wsdlutput message="impl:closeSessionResponse"
name="closeSessionResponse" />
</wsdlperation>

</wsdlortType>

<wsdl:binding name="MynameServiceSoapBinding" type="impl:MynameService">
<wsdlsoap:binding style="document"
transport="http://schemas.xmlsoap.org/soap/http" />

<wsdlperation name="getSession">
<wsdlsoapperation soapAction="" />
<wsdl:input name="getSessionRequest">
<wsdlsoap:header message="impl:soapHeader" part="sessionID"
use="literal"/>
<wsdlsoap:body namespace="urn:myname.com" use="literal" />
</wsdl:input>
<wsdlutput name="getSessionResponse">
<!-- comment it out. There is another bug in .net for this -->
<!-- wsdlsoap:header message="impl:soapHeader" part="sessionID"
use="literal"/ -->
<wsdlsoap:body namespace="urn:myname.com" use="literal" />
</wsdlutput>
</wsdlperation>

<wsdlperation name="closeSession">
<wsdlsoapperation soapAction="" />
<wsdl:input name="closeSessionRequest">
<wsdlsoap:header message="impl:soapHeader" part="sessionID"
use="literal"/>
<wsdlsoap:body namespace="urn:myname.com" use="literal" />
</wsdl:input>
<wsdlutput name="closeSessionResponse">
<wsdlsoap:header message="impl:soapHeader" part="sessionID"
use="literal"/>
<wsdlsoap:body namespace="urn:myname.com" use="literal" />
</wsdlutput>
</wsdlperation>

</wsdl:binding>

<wsdl:service name="MynameServiceService">
<wsdlort binding="impl:MynameServiceSoapBinding" name="MynameService">
<wsdlsoap:address
location="http://localhost:8080/services/MynameService" />
</wsdlort>
</wsdl:service>

</wsdl:definitions>

============================================

Generated cs file:
============================================
namespace MyNameSpace{
using System.Diagnostics;
using System.Xml.Serialization;
using System;
using System.Web.Services.Protocols;
using System.ComponentModel;
using System.Web.Services;


/// <remarks/>
[System.Diagnostics.DebuggerStepThroughAttribute()]
[System.ComponentModel.DesignerCategoryAttribute("c ode")]

[System.Web.Services.WebServiceBindingAttribute(Nam e="MynameServiceSoapBindi
ng", Namespace="urn:myname.com")]
public class MynameServiceService :
System.Web.Services.Protocols.SoapHttpClientProtoc ol {

public session sessionID;

/// <remarks/>
public MynameServiceService() {
this.Url = "http://localhost:8080/services/MynameService";
}

/// <remarks/>
[System.Web.Services.Protocols.SoapHeaderAttribute( "sessionID")]
[System.Web.Services.Protocols.SoapDocumentMethodAt tribute("",
RequestNamespace="urn:myname.com", ResponseNamespace="urn:myname.com",
Use=System.Web.Services.Description.SoapBindingUse .Literal,
ParameterStyle=System.Web.Services.Protocols.SoapP arameterStyle.Wrapped)]
[return:
System.Xml.Serialization.XmlElementAttribute("getS essionReturn",
Form=System.Xml.Schema.XmlSchemaForm.Unqualified)]
public string
getSession([System.Xml.Serialization.XmlElementAttribute(Form= System.Xml.Sch
ema.XmlSchemaForm.Unqualified)] string username,
[System.Xml.Serialization.XmlElementAttribute(Form= System.Xml.Schema.XmlSche
maForm.Unqualified)] string password) {
object[] results = this.Invoke("getSession", new object[] {
username,
password});
return ((string)(results[0]));
}

/// <remarks/>
public System.IAsyncResult BegingetSession(string username, string
password, System.AsyncCallback callback, object asyncState) {
return this.BeginInvoke("getSession", new object[] {
username,
password}, callback, asyncState);
}

/// <remarks/>
public string EndgetSession(System.IAsyncResult asyncResult) {
object[] results = this.EndInvoke(asyncResult);
return ((string)(results[0]));
}

/// <remarks/>
[System.Web.Services.Protocols.SoapHeaderAttribute( "sessionID",
Direction=System.Web.Services.Protocols.SoapHeader Direction.InOut)]
[System.Web.Services.Protocols.SoapDocumentMethodAt tribute("",
RequestNamespace="urn:myname.com", ResponseNamespace="urn:myname.com",
Use=System.Web.Services.Description.SoapBindingUse .Literal,
ParameterStyle=System.Web.Services.Protocols.SoapP arameterStyle.Wrapped)]
public void closeSession() {
this.Invoke("closeSession", new object[0]);
}

/// <remarks/>
public System.IAsyncResult BegincloseSession(System.AsyncCallback
callback, object asyncState) {
return this.BeginInvoke("closeSession", new object[0], callback,
asyncState);
}

/// <remarks/>
public void EndcloseSession(System.IAsyncResult asyncResult) {
this.EndInvoke(asyncResult);
}
}

/// <remarks/>

[System.Xml.Serialization.XmlTypeAttribute(Namespac e="http://xml.apache.org/
axis/session")]
[System.Xml.Serialization.XmlRootAttribute("session ID",
Namespace="http://xml.apache.org/axis/session", IsNullable=false)]
public class session : System.Web.Services.Protocols.SoapHeader {

/// <remarks/>
[System.Xml.Serialization.XmlTextAttribute()]
public string[] Text;
}
}

==================================================


"Dino Chiesa [Microsoft]" <(E-Mail Removed)> wrote in message
news:%(E-Mail Removed)...
> you showed the request and response - I guess that would be a request from
> .NET to AXIS and a response from AXIS to .NET.
> Can I see the WSDL? or failing that, the client-side proxy generated by
> wsdl.exe ??
>
> I am betting it is an xml namespace issue.
>
> -D
>
> "Zihong Lu" <(E-Mail Removed)> wrote in message
> news:(E-Mail Removed) om...
> > I have used the following settings in our web services:
> >
> > .net framework 1.1 web services client
> > Axis 1.1 server (in wsdd file, set style="wrapped")
> >
> > Using axis client calls the server, it works fine. However, .net
> > client always returns null, even though the soap message has the
> > result, for example, for the simple function
> >
> > string getSession(string username, string password);
> >
> > The SOAP messages in the response seems to be normal, as shown in this
> > request/response message:
> >
> > ====== Request ======
> > <?xml version="1.0" encoding="utf-8"?>
> > <soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"
> > xmlnssi="http://www.w3.org/2001/XMLSchema-instance"
> > xmlnssd="http://www.w3.org/2001/XMLSchema">
> > <soap:Body>
> > <getSession xmlns="urn:myname.com">
> > <username xmlns="">admin</username>
> > <password xmlns="" />
> > </getSession>
> > </soap:Body>
> > </soap:Envelope>
> >
> > ====== Response ======
> > 287
> > <?xml version="1.0" encoding="utf-8"?>
> > <soapenv:Envelope

> xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
> > xmlnssd="http://www.w3.org/2001/XMLSchema"
> > xmlnssi="http://www.w3.org/2001/XMLSchema-instance">
> > <soapenv:Header>
> > <ns1:sessionID

> soapenv:actor="http://schemas.xmlsoap.org/soap/actor/next"
> > soapenv:mustUnderstand="0"
> > xmlns:ns1="http://xml.apache.org/axis/session">
> > 7413200230928429396
> > </ns1:sessionID>
> > </soapenv:Header>
> > <soapenv:Body>
> > <getSessionResponse xmlns="urn:myname.com">
> > <getSessionReturn>7413200230928429396</getSessionReturn>
> > </getSessionResponse>
> > </soapenv:Body>
> > </soapenv:Envelope>
> > 0
> >
> >
> > No, I don't know why there is a 287 before <?xml> tag and a 0 at the
> > end of the response message. This may have something to do with the
> > response HTTP header
> >
> > Transfer-Encoding: chunked
> >
> > in responding to the .net request HTTP header of "Connection:
> > Keep-Alive".
> >
> > The session ID in SOAP header doesn't seem matter, since I tested the
> > call with and without the session ID header. I have serached this
> > group for almost a day, the closest I have found is this link:
> >
> >

>

http://groups.google.com/groups?selm...ing.google.com
> >
> > However, it was talking about serializing complex type there. Can
> > someone plese help?
> >
> >
> > -Zihong

>
>



 
Reply With Quote
 
Dino Chiesa [Microsoft]
Guest
Posts: n/a
 
      06-19-2004
Yes, A namespace problem .
To fix this
change the attribute on the getSession() method in the generated client side
proxy to Qualified, from Unqualified

[return: System.Xml.Serialization.XmlElementAttribute("getS essionReturn",
Form=System.Xml.Schema.XmlSchemaForm.Qualified)]

Or, you can modify the WSDL to accurately reflect what AXIS is sending back:

<element name="getSessionReturn" type="xsd:string" form="qualified" />

and then regenerate the client proxy.

AXIS is a bit loose with its elementforms (qualified vs unqualified). The
WSDL doesn't specify it, yet the behavior for the request and response is
different.
-D


"Zihong Lu" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> Dino,
>
> Thank you for looking into this. Yes the request/response messages are
> .net->axis (request) and axis->.net(response).
>
> Here is the WSDL that I use (Note that I commented out the
> <wsdlsoap:header message="impl:soapHeader" part="sessionID"

use="literal"/>
> for getSession(),
> because it is another issue that causing .net confused, it does not know
> what "xsd:long" is.)
> ==================================
> <?xml version="1.0" encoding="UTF-8" ?>
> <wsdl:definitions targetNamespace="urn:myname.com"
> xmlns="http://schemas.xmlsoap.org/wsdl/"
> xmlns:apachesoap="http://xml.apache.org/xml-soap"
> xmlns:impl="urn:myname.com"
> xmlns:intf="urn:myname.com"
> xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/"
> xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
> xmlns:wsdlsoap="http://schemas.xmlsoap.org/wsdl/soap/"
> xmlnssd="http://www.w3.org/2001/XMLSchema"
> xmlns:session="http://xml.apache.org/axis/session">
>
> <documentation />
>
> <wsdl:types>
>
> <schema targetNamespace="http://xml.apache.org/axis/session"
> xmlns="http://www.w3.org/2001/XMLSchema">
> <simpleType name="session">
> <restriction base="xsd:long"/>
> </simpleType>
> <element name="sessionID" type="session:session"/>
> </schema>
>
> <schema targetNamespace="urn:myname.com"
> xmlns="http://www.w3.org/2001/XMLSchema">
>
>
> <element name="getSession">
> <complexType>
> <sequence>
> <element name="username" type="xsd:string" />
> <element name="password" type="xsd:string" />
> </sequence>
> </complexType>
> </element>
>
> <element name="getSessionResponse">
> <complexType>
> <sequence>
> <element name="getSessionReturn" type="xsd:string" />
> </sequence>
> </complexType>
> </element>
>
> <element name="closeSession">
> <complexType />
> </element>
>
> <element name="closeSessionResponse">
> <complexType />
> </element>
>
> </schema>
> </wsdl:types>
>
> <wsdl:message name="soapHeader">
> <wsdlart name="sessionID" element="session:sessionID" />
> </wsdl:message>
>
> <wsdl:message name="getSessionRequest">
> <wsdlart element="impl:getSession" name="parameters" />
> </wsdl:message>
>
> <wsdl:message name="getSessionResponse">
> <wsdlart element="impl:getSessionResponse" name="parameters" />
> </wsdl:message>
>
> <wsdl:message name="closeSessionRequest">
> <wsdlart element="impl:closeSession" name="parameters" />
> </wsdl:message>
>
> <wsdl:message name="closeSessionResponse">
> <wsdlart element="impl:closeSessionResponse" name="parameters" />
> </wsdl:message>
>
> <wsdlortType name="MynameService">
>
> <wsdlperation name="getSession" parameterOrder="">
> <wsdl:input message="impl:getSessionRequest"
> name="getSessionRequest" />
> <wsdlutput message="impl:getSessionResponse"
> name="getSessionResponse" />
> </wsdlperation>
>
> <wsdlperation name="closeSession">
> <wsdl:input message="impl:closeSessionRequest"
> name="closeSessionRequest" />
> <wsdlutput message="impl:closeSessionResponse"
> name="closeSessionResponse" />
> </wsdlperation>
>
> </wsdlortType>
>
> <wsdl:binding name="MynameServiceSoapBinding" type="impl:MynameService">
> <wsdlsoap:binding style="document"
> transport="http://schemas.xmlsoap.org/soap/http" />
>
> <wsdlperation name="getSession">
> <wsdlsoapperation soapAction="" />
> <wsdl:input name="getSessionRequest">
> <wsdlsoap:header message="impl:soapHeader" part="sessionID"
> use="literal"/>
> <wsdlsoap:body namespace="urn:myname.com" use="literal" />
> </wsdl:input>
> <wsdlutput name="getSessionResponse">
> <!-- comment it out. There is another bug in .net for

this -->
> <!-- wsdlsoap:header message="impl:soapHeader"

part="sessionID"
> use="literal"/ -->
> <wsdlsoap:body namespace="urn:myname.com" use="literal" />
> </wsdlutput>
> </wsdlperation>
>
> <wsdlperation name="closeSession">
> <wsdlsoapperation soapAction="" />
> <wsdl:input name="closeSessionRequest">
> <wsdlsoap:header message="impl:soapHeader" part="sessionID"
> use="literal"/>
> <wsdlsoap:body namespace="urn:myname.com" use="literal" />
> </wsdl:input>
> <wsdlutput name="closeSessionResponse">
> <wsdlsoap:header message="impl:soapHeader" part="sessionID"
> use="literal"/>
> <wsdlsoap:body namespace="urn:myname.com" use="literal" />
> </wsdlutput>
> </wsdlperation>
>
> </wsdl:binding>
>
> <wsdl:service name="MynameServiceService">
> <wsdlort binding="impl:MynameServiceSoapBinding"

name="MynameService">
> <wsdlsoap:address
> location="http://localhost:8080/services/MynameService" />
> </wsdlort>
> </wsdl:service>
>
> </wsdl:definitions>
>
> ============================================
>
> Generated cs file:
> ============================================
> namespace MyNameSpace{
> using System.Diagnostics;
> using System.Xml.Serialization;
> using System;
> using System.Web.Services.Protocols;
> using System.ComponentModel;
> using System.Web.Services;
>
>
> /// <remarks/>
> [System.Diagnostics.DebuggerStepThroughAttribute()]
> [System.ComponentModel.DesignerCategoryAttribute("c ode")]
>
>

[System.Web.Services.WebServiceBindingAttribute(Nam e="MynameServiceSoapBindi
> ng", Namespace="urn:myname.com")]
> public class MynameServiceService :
> System.Web.Services.Protocols.SoapHttpClientProtoc ol {
>
> public session sessionID;
>
> /// <remarks/>
> public MynameServiceService() {
> this.Url = "http://localhost:8080/services/MynameService";
> }
>
> /// <remarks/>
> [System.Web.Services.Protocols.SoapHeaderAttribute( "sessionID")]
> [System.Web.Services.Protocols.SoapDocumentMethodAt tribute("",
> RequestNamespace="urn:myname.com", ResponseNamespace="urn:myname.com",
> Use=System.Web.Services.Description.SoapBindingUse .Literal,
> ParameterStyle=System.Web.Services.Protocols.SoapP arameterStyle.Wrapped)]
> [return:
> System.Xml.Serialization.XmlElementAttribute("getS essionReturn",
> Form=System.Xml.Schema.XmlSchemaForm.Unqualified)]
> public string
>

getSession([System.Xml.Serialization.XmlElementAttribute(Form= System.Xml.Sch
> ema.XmlSchemaForm.Unqualified)] string username,
>

[System.Xml.Serialization.XmlElementAttribute(Form= System.Xml.Schema.XmlSche
> maForm.Unqualified)] string password) {
> object[] results = this.Invoke("getSession", new object[] {
> username,
> password});
> return ((string)(results[0]));
> }
>
> /// <remarks/>
> public System.IAsyncResult BegingetSession(string username, string
> password, System.AsyncCallback callback, object asyncState) {
> return this.BeginInvoke("getSession", new object[] {
> username,
> password}, callback, asyncState);
> }
>
> /// <remarks/>
> public string EndgetSession(System.IAsyncResult asyncResult) {
> object[] results = this.EndInvoke(asyncResult);
> return ((string)(results[0]));
> }
>
> /// <remarks/>
> [System.Web.Services.Protocols.SoapHeaderAttribute( "sessionID",
> Direction=System.Web.Services.Protocols.SoapHeader Direction.InOut)]
> [System.Web.Services.Protocols.SoapDocumentMethodAt tribute("",
> RequestNamespace="urn:myname.com", ResponseNamespace="urn:myname.com",
> Use=System.Web.Services.Description.SoapBindingUse .Literal,
> ParameterStyle=System.Web.Services.Protocols.SoapP arameterStyle.Wrapped)]
> public void closeSession() {
> this.Invoke("closeSession", new object[0]);
> }
>
> /// <remarks/>
> public System.IAsyncResult BegincloseSession(System.AsyncCallback
> callback, object asyncState) {
> return this.BeginInvoke("closeSession", new object[0],

callback,
> asyncState);
> }
>
> /// <remarks/>
> public void EndcloseSession(System.IAsyncResult asyncResult) {
> this.EndInvoke(asyncResult);
> }
> }
>
> /// <remarks/>
>
>

[System.Xml.Serialization.XmlTypeAttribute(Namespac e="http://xml.apache.org/
> axis/session")]
> [System.Xml.Serialization.XmlRootAttribute("session ID",
> Namespace="http://xml.apache.org/axis/session", IsNullable=false)]
> public class session : System.Web.Services.Protocols.SoapHeader {
>
> /// <remarks/>
> [System.Xml.Serialization.XmlTextAttribute()]
> public string[] Text;
> }
> }
>
> ==================================================
>
>
> "Dino Chiesa [Microsoft]" <(E-Mail Removed)> wrote in message
> news:%(E-Mail Removed)...
> > you showed the request and response - I guess that would be a request

from
> > .NET to AXIS and a response from AXIS to .NET.
> > Can I see the WSDL? or failing that, the client-side proxy generated by
> > wsdl.exe ??
> >
> > I am betting it is an xml namespace issue.
> >
> > -D
> >
> > "Zihong Lu" <(E-Mail Removed)> wrote in message
> > news:(E-Mail Removed) om...
> > > I have used the following settings in our web services:
> > >
> > > .net framework 1.1 web services client
> > > Axis 1.1 server (in wsdd file, set style="wrapped")
> > >
> > > Using axis client calls the server, it works fine. However, .net
> > > client always returns null, even though the soap message has the
> > > result, for example, for the simple function
> > >
> > > string getSession(string username, string password);
> > >
> > > The SOAP messages in the response seems to be normal, as shown in this
> > > request/response message:
> > >
> > > ====== Request ======
> > > <?xml version="1.0" encoding="utf-8"?>
> > > <soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"
> > > xmlnssi="http://www.w3.org/2001/XMLSchema-instance"
> > > xmlnssd="http://www.w3.org/2001/XMLSchema">
> > > <soap:Body>
> > > <getSession xmlns="urn:myname.com">
> > > <username xmlns="">admin</username>
> > > <password xmlns="" />
> > > </getSession>
> > > </soap:Body>
> > > </soap:Envelope>
> > >
> > > ====== Response ======
> > > 287
> > > <?xml version="1.0" encoding="utf-8"?>
> > > <soapenv:Envelope

> > xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
> > > xmlnssd="http://www.w3.org/2001/XMLSchema"
> > > xmlnssi="http://www.w3.org/2001/XMLSchema-instance">
> > > <soapenv:Header>
> > > <ns1:sessionID

> > soapenv:actor="http://schemas.xmlsoap.org/soap/actor/next"
> > > soapenv:mustUnderstand="0"
> > > xmlns:ns1="http://xml.apache.org/axis/session">
> > > 7413200230928429396
> > > </ns1:sessionID>
> > > </soapenv:Header>
> > > <soapenv:Body>
> > > <getSessionResponse xmlns="urn:myname.com">
> > > <getSessionReturn>7413200230928429396</getSessionReturn>
> > > </getSessionResponse>
> > > </soapenv:Body>
> > > </soapenv:Envelope>
> > > 0
> > >
> > >
> > > No, I don't know why there is a 287 before <?xml> tag and a 0 at the
> > > end of the response message. This may have something to do with the
> > > response HTTP header
> > >
> > > Transfer-Encoding: chunked
> > >
> > > in responding to the .net request HTTP header of "Connection:
> > > Keep-Alive".
> > >
> > > The session ID in SOAP header doesn't seem matter, since I tested the
> > > call with and without the session ID header. I have serached this
> > > group for almost a day, the closest I have found is this link:
> > >
> > >

> >

>

http://groups.google.com/groups?selm...ing.google.com
> > >
> > > However, it was talking about serializing complex type there. Can
> > > someone plese help?
> > >
> > >
> > > -Zihong

> >
> >

>
>



 
Reply With Quote
 
Zihong Lu
Guest
Posts: n/a
 
      06-20-2004
Dino,

Thanks. That works.

Now I have a second issue: the soap header. As you can see from my eariler
wsdl file, if I do the following:
(1) changed the line to <element name="getSessionReturn" type="xsd:string"
form="qualified"/>, to solve the null result problem;
(2) uncommented out the line to indicate the soap header in the return
message:
<wsdlsoap:header message="impl:soapHeader" part="sessionID" use="literal"
/>

When invoke the getSession() call, the .net client complained:

=========================================
System.InvalidOperationException: The specified type was not recognized:
name='long',
namespace='http://www.w3.org/2001/XMLSchema', at <sessionID
xmlns='http://xml.apache.org/axis/session'>.

at
Microsoft.Xml.Serialization.GeneratedAssembly.XmlS erializationReader1.Read1_
session(Boolean isNullable, Boolean checkType)
at
Microsoft.Xml.Serialization.GeneratedAssembly.XmlS erializationReader1.Read8_
OutHeaders()

Do I need to create serializer/deserializer for the SOAP header? I thought
the created proxy code already recognize it and can serialize it
automatically, like gSoap does.

Here is the new generated client proxy:
============================
namespace MyNameSpace{
using System.Diagnostics;
using System.Xml.Serialization;
using System;
using System.Web.Services.Protocols;
using System.ComponentModel;
using System.Web.Services;


/// <remarks/>
[System.Diagnostics.DebuggerStepThroughAttribute()]
[System.ComponentModel.DesignerCategoryAttribute("c ode")]

[System.Web.Services.WebServiceBindingAttribute(Nam e="MynameServiceSoapBindi
ng", Namespace="urn:myname.com")]
public class MynameServiceService :
System.Web.Services.Protocols.SoapHttpClientProtoc ol {

public session sessionID;

/// <remarks/>
public MynameServiceService() {
this.Url = "http://localhost:8080/services/MynameService";
}

/// <remarks/>
[System.Web.Services.Protocols.SoapHeaderAttribute( "sessionID",
Direction=System.Web.Services.Protocols.SoapHeader Direction.InOut)]
[System.Web.Services.Protocols.SoapDocumentMethodAt tribute("",
RequestNamespace="urn:myname.com", ResponseNamespace="urn:myname.com",
Use=System.Web.Services.Description.SoapBindingUse .Literal,
ParameterStyle=System.Web.Services.Protocols.SoapP arameterStyle.Wrapped)]
[return:
System.Xml.Serialization.XmlElementAttribute("getS essionReturn")]
public string
getSession([System.Xml.Serialization.XmlElementAttribute(Form= System.Xml.Sch
ema.XmlSchemaForm.Unqualified)] string username,
[System.Xml.Serialization.XmlElementAttribute(Form= System.Xml.Schema.XmlSche
maForm.Unqualified)] string password) {
object[] results = this.Invoke("getSession", new object[] {
username,
password});
return ((string)(results[0]));
}

/// <remarks/>
public System.IAsyncResult BegingetSession(string username, string
password, System.AsyncCallback callback, object asyncState) {
return this.BeginInvoke("getSession", new object[] {
username,
password}, callback, asyncState);
}

/// <remarks/>
public string EndgetSession(System.IAsyncResult asyncResult) {
object[] results = this.EndInvoke(asyncResult);
return ((string)(results[0]));
}

/// <remarks/>
[System.Web.Services.Protocols.SoapHeaderAttribute( "sessionID",
Direction=System.Web.Services.Protocols.SoapHeader Direction.InOut)]
[System.Web.Services.Protocols.SoapDocumentMethodAt tribute("",
RequestNamespace="urn:myname.com", ResponseNamespace="urn:myname.com",
Use=System.Web.Services.Description.SoapBindingUse .Literal,
ParameterStyle=System.Web.Services.Protocols.SoapP arameterStyle.Wrapped)]
public void closeSession() {
this.Invoke("closeSession", new object[0]);
}

/// <remarks/>
public System.IAsyncResult BegincloseSession(System.AsyncCallback
callback, object asyncState) {
return this.BeginInvoke("closeSession", new object[0], callback,
asyncState);
}

/// <remarks/>
public void EndcloseSession(System.IAsyncResult asyncResult) {
this.EndInvoke(asyncResult);
}
}

/// <remarks/>

[System.Xml.Serialization.XmlTypeAttribute(Namespac e="http://xml.apache.org/
axis/session")]
[System.Xml.Serialization.XmlRootAttribute("session ID",
Namespace="http://xml.apache.org/axis/session", IsNullable=false)]
public class session : System.Web.Services.Protocols.SoapHeader {

/// <remarks/>
[System.Xml.Serialization.XmlTextAttribute()]
public string[] Text;
}
}







"Dino Chiesa [Microsoft]" <(E-Mail Removed)> wrote in message
news:%(E-Mail Removed)...
> Yes, A namespace problem .
> To fix this
> change the attribute on the getSession() method in the generated client

side
> proxy to Qualified, from Unqualified
>
> [return:

System.Xml.Serialization.XmlElementAttribute("getS essionReturn",
> Form=System.Xml.Schema.XmlSchemaForm.Qualified)]
>
> Or, you can modify the WSDL to accurately reflect what AXIS is sending

back:
>
> <element name="getSessionReturn" type="xsd:string" form="qualified" />
>
> and then regenerate the client proxy.
>
> AXIS is a bit loose with its elementforms (qualified vs unqualified). The
> WSDL doesn't specify it, yet the behavior for the request and response is
> different.
> -D
>
>
> "Zihong Lu" <(E-Mail Removed)> wrote in message
> news:(E-Mail Removed)...
> > Dino,
> >
> > Thank you for looking into this. Yes the request/response messages are
> > .net->axis (request) and axis->.net(response).
> >
> > Here is the WSDL that I use (Note that I commented out the
> > <wsdlsoap:header message="impl:soapHeader" part="sessionID"

> use="literal"/>
> > for getSession(),
> > because it is another issue that causing .net confused, it does not know
> > what "xsd:long" is.)
> > ==================================
> > <?xml version="1.0" encoding="UTF-8" ?>
> > <wsdl:definitions targetNamespace="urn:myname.com"
> > xmlns="http://schemas.xmlsoap.org/wsdl/"
> > xmlns:apachesoap="http://xml.apache.org/xml-soap"
> > xmlns:impl="urn:myname.com"
> > xmlns:intf="urn:myname.com"
> > xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/"
> > xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
> > xmlns:wsdlsoap="http://schemas.xmlsoap.org/wsdl/soap/"
> > xmlnssd="http://www.w3.org/2001/XMLSchema"
> > xmlns:session="http://xml.apache.org/axis/session">
> >
> > <documentation />
> >
> > <wsdl:types>
> >
> > <schema targetNamespace="http://xml.apache.org/axis/session"
> > xmlns="http://www.w3.org/2001/XMLSchema">
> > <simpleType name="session">
> > <restriction base="xsd:long"/>
> > </simpleType>
> > <element name="sessionID" type="session:session"/>
> > </schema>
> >
> > <schema targetNamespace="urn:myname.com"
> > xmlns="http://www.w3.org/2001/XMLSchema">
> >
> >
> > <element name="getSession">
> > <complexType>
> > <sequence>
> > <element name="username" type="xsd:string" />
> > <element name="password" type="xsd:string" />
> > </sequence>
> > </complexType>
> > </element>
> >
> > <element name="getSessionResponse">
> > <complexType>
> > <sequence>
> > <element name="getSessionReturn" type="xsd:string" />
> > </sequence>
> > </complexType>
> > </element>
> >
> > <element name="closeSession">
> > <complexType />
> > </element>
> >
> > <element name="closeSessionResponse">
> > <complexType />
> > </element>
> >
> > </schema>
> > </wsdl:types>
> >
> > <wsdl:message name="soapHeader">
> > <wsdlart name="sessionID" element="session:sessionID" />
> > </wsdl:message>
> >
> > <wsdl:message name="getSessionRequest">
> > <wsdlart element="impl:getSession" name="parameters" />
> > </wsdl:message>
> >
> > <wsdl:message name="getSessionResponse">
> > <wsdlart element="impl:getSessionResponse" name="parameters" />
> > </wsdl:message>
> >
> > <wsdl:message name="closeSessionRequest">
> > <wsdlart element="impl:closeSession" name="parameters" />
> > </wsdl:message>
> >
> > <wsdl:message name="closeSessionResponse">
> > <wsdlart element="impl:closeSessionResponse" name="parameters" />
> > </wsdl:message>
> >
> > <wsdlortType name="MynameService">
> >
> > <wsdlperation name="getSession" parameterOrder="">
> > <wsdl:input message="impl:getSessionRequest"
> > name="getSessionRequest" />
> > <wsdlutput message="impl:getSessionResponse"
> > name="getSessionResponse" />
> > </wsdlperation>
> >
> > <wsdlperation name="closeSession">
> > <wsdl:input message="impl:closeSessionRequest"
> > name="closeSessionRequest" />
> > <wsdlutput message="impl:closeSessionResponse"
> > name="closeSessionResponse" />
> > </wsdlperation>
> >
> > </wsdlortType>
> >
> > <wsdl:binding name="MynameServiceSoapBinding" type="impl:MynameService">
> > <wsdlsoap:binding style="document"
> > transport="http://schemas.xmlsoap.org/soap/http" />
> >
> > <wsdlperation name="getSession">
> > <wsdlsoapperation soapAction="" />
> > <wsdl:input name="getSessionRequest">
> > <wsdlsoap:header message="impl:soapHeader" part="sessionID"
> > use="literal"/>
> > <wsdlsoap:body namespace="urn:myname.com" use="literal" />
> > </wsdl:input>
> > <wsdlutput name="getSessionResponse">
> > <!-- comment it out. There is another bug in .net for

> this -->
> > <!-- wsdlsoap:header message="impl:soapHeader"

> part="sessionID"
> > use="literal"/ -->
> > <wsdlsoap:body namespace="urn:myname.com" use="literal" />
> > </wsdlutput>
> > </wsdlperation>
> >
> > <wsdlperation name="closeSession">
> > <wsdlsoapperation soapAction="" />
> > <wsdl:input name="closeSessionRequest">
> > <wsdlsoap:header message="impl:soapHeader" part="sessionID"
> > use="literal"/>
> > <wsdlsoap:body namespace="urn:myname.com" use="literal" />
> > </wsdl:input>
> > <wsdlutput name="closeSessionResponse">
> > <wsdlsoap:header message="impl:soapHeader" part="sessionID"
> > use="literal"/>
> > <wsdlsoap:body namespace="urn:myname.com" use="literal" />
> > </wsdlutput>
> > </wsdlperation>
> >
> > </wsdl:binding>
> >
> > <wsdl:service name="MynameServiceService">
> > <wsdlort binding="impl:MynameServiceSoapBinding"

> name="MynameService">
> > <wsdlsoap:address
> > location="http://localhost:8080/services/MynameService" />
> > </wsdlort>
> > </wsdl:service>
> >
> > </wsdl:definitions>
> >
> > ============================================
> >
> > Generated cs file:
> > ============================================
> > namespace MyNameSpace{
> > using System.Diagnostics;
> > using System.Xml.Serialization;
> > using System;
> > using System.Web.Services.Protocols;
> > using System.ComponentModel;
> > using System.Web.Services;
> >
> >
> > /// <remarks/>
> > [System.Diagnostics.DebuggerStepThroughAttribute()]
> > [System.ComponentModel.DesignerCategoryAttribute("c ode")]
> >
> >

>

[System.Web.Services.WebServiceBindingAttribute(Nam e="MynameServiceSoapBindi
> > ng", Namespace="urn:myname.com")]
> > public class MynameServiceService :
> > System.Web.Services.Protocols.SoapHttpClientProtoc ol {
> >
> > public session sessionID;
> >
> > /// <remarks/>
> > public MynameServiceService() {
> > this.Url = "http://localhost:8080/services/MynameService";
> > }
> >
> > /// <remarks/>
> > [System.Web.Services.Protocols.SoapHeaderAttribute( "sessionID")]
> > [System.Web.Services.Protocols.SoapDocumentMethodAt tribute("",
> > RequestNamespace="urn:myname.com", ResponseNamespace="urn:myname.com",
> > Use=System.Web.Services.Description.SoapBindingUse .Literal,
> >

ParameterStyle=System.Web.Services.Protocols.SoapP arameterStyle.Wrapped)]
> > [return:
> > System.Xml.Serialization.XmlElementAttribute("getS essionReturn",
> > Form=System.Xml.Schema.XmlSchemaForm.Unqualified)]
> > public string
> >

>

getSession([System.Xml.Serialization.XmlElementAttribute(Form= System.Xml.Sch
> > ema.XmlSchemaForm.Unqualified)] string username,
> >

>

[System.Xml.Serialization.XmlElementAttribute(Form= System.Xml.Schema.XmlSche
> > maForm.Unqualified)] string password) {
> > object[] results = this.Invoke("getSession", new object[] {
> > username,
> > password});
> > return ((string)(results[0]));
> > }
> >
> > /// <remarks/>
> > public System.IAsyncResult BegingetSession(string username,

string
> > password, System.AsyncCallback callback, object asyncState) {
> > return this.BeginInvoke("getSession", new object[] {
> > username,
> > password}, callback, asyncState);
> > }
> >
> > /// <remarks/>
> > public string EndgetSession(System.IAsyncResult asyncResult) {
> > object[] results = this.EndInvoke(asyncResult);
> > return ((string)(results[0]));
> > }
> >
> > /// <remarks/>
> > [System.Web.Services.Protocols.SoapHeaderAttribute( "sessionID",
> > Direction=System.Web.Services.Protocols.SoapHeader Direction.InOut)]
> > [System.Web.Services.Protocols.SoapDocumentMethodAt tribute("",
> > RequestNamespace="urn:myname.com", ResponseNamespace="urn:myname.com",
> > Use=System.Web.Services.Description.SoapBindingUse .Literal,
> >

ParameterStyle=System.Web.Services.Protocols.SoapP arameterStyle.Wrapped)]
> > public void closeSession() {
> > this.Invoke("closeSession", new object[0]);
> > }
> >
> > /// <remarks/>
> > public System.IAsyncResult

BegincloseSession(System.AsyncCallback
> > callback, object asyncState) {
> > return this.BeginInvoke("closeSession", new object[0],

> callback,
> > asyncState);
> > }
> >
> > /// <remarks/>
> > public void EndcloseSession(System.IAsyncResult asyncResult) {
> > this.EndInvoke(asyncResult);
> > }
> > }
> >
> > /// <remarks/>
> >
> >

>

[System.Xml.Serialization.XmlTypeAttribute(Namespac e="http://xml.apache.org/
> > axis/session")]
> > [System.Xml.Serialization.XmlRootAttribute("session ID",
> > Namespace="http://xml.apache.org/axis/session", IsNullable=false)]
> > public class session : System.Web.Services.Protocols.SoapHeader {
> >
> > /// <remarks/>
> > [System.Xml.Serialization.XmlTextAttribute()]
> > public string[] Text;
> > }
> > }
> >
> > ==================================================
> >
> >
> > "Dino Chiesa [Microsoft]" <(E-Mail Removed)> wrote in message
> > news:%(E-Mail Removed)...
> > > you showed the request and response - I guess that would be a request

> from
> > > .NET to AXIS and a response from AXIS to .NET.
> > > Can I see the WSDL? or failing that, the client-side proxy generated

by
> > > wsdl.exe ??
> > >
> > > I am betting it is an xml namespace issue.
> > >
> > > -D
> > >
> > > "Zihong Lu" <(E-Mail Removed)> wrote in message
> > > news:(E-Mail Removed) om...
> > > > I have used the following settings in our web services:
> > > >
> > > > .net framework 1.1 web services client
> > > > Axis 1.1 server (in wsdd file, set style="wrapped")
> > > >
> > > > Using axis client calls the server, it works fine. However, .net
> > > > client always returns null, even though the soap message has the
> > > > result, for example, for the simple function
> > > >
> > > > string getSession(string username, string password);
> > > >
> > > > The SOAP messages in the response seems to be normal, as shown in

this
> > > > request/response message:
> > > >
> > > > ====== Request ======
> > > > <?xml version="1.0" encoding="utf-8"?>
> > > > <soap:Envelope

xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"
> > > > xmlnssi="http://www.w3.org/2001/XMLSchema-instance"
> > > > xmlnssd="http://www.w3.org/2001/XMLSchema">
> > > > <soap:Body>
> > > > <getSession xmlns="urn:myname.com">
> > > > <username xmlns="">admin</username>
> > > > <password xmlns="" />
> > > > </getSession>
> > > > </soap:Body>
> > > > </soap:Envelope>
> > > >
> > > > ====== Response ======
> > > > 287
> > > > <?xml version="1.0" encoding="utf-8"?>
> > > > <soapenv:Envelope
> > > xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
> > > > xmlnssd="http://www.w3.org/2001/XMLSchema"
> > > > xmlnssi="http://www.w3.org/2001/XMLSchema-instance">
> > > > <soapenv:Header>
> > > > <ns1:sessionID
> > > soapenv:actor="http://schemas.xmlsoap.org/soap/actor/next"
> > > > soapenv:mustUnderstand="0"
> > > > xmlns:ns1="http://xml.apache.org/axis/session">
> > > > 7413200230928429396
> > > > </ns1:sessionID>
> > > > </soapenv:Header>
> > > > <soapenv:Body>
> > > > <getSessionResponse xmlns="urn:myname.com">
> > > > <getSessionReturn>7413200230928429396</getSessionReturn>
> > > > </getSessionResponse>
> > > > </soapenv:Body>
> > > > </soapenv:Envelope>
> > > > 0
> > > >
> > > >
> > > > No, I don't know why there is a 287 before <?xml> tag and a 0 at the
> > > > end of the response message. This may have something to do with the
> > > > response HTTP header
> > > >
> > > > Transfer-Encoding: chunked
> > > >
> > > > in responding to the .net request HTTP header of "Connection:
> > > > Keep-Alive".
> > > >
> > > > The session ID in SOAP header doesn't seem matter, since I tested

the
> > > > call with and without the session ID header. I have serached this
> > > > group for almost a day, the closest I have found is this link:
> > > >
> > > >
> > >

> >

>

http://groups.google.com/groups?selm...ing.google.com
> > > >
> > > > However, it was talking about serializing complex type there. Can
> > > > someone plese help?
> > > >
> > > >
> > > > -Zihong
> > >
> > >

> >
> >

>
>



 
Reply With Quote
 
Dino Chiesa [Microsoft]
Guest
Posts: n/a
 
      06-21-2004
If I modify your WSDL to type the session ID this way:

<element name="sessionID" type="sess:session"/>

<complexType name="session">
<sequence>
<element minOccurs="1" maxOccurs="1" name="s" type="xsd:long"/>
</sequence>
</complexType>


it works, and generates a header class like so:

public class session : System.Web.Services.Protocols.SoapHeader {
/// <remarks/>
[System.Xml.Serialization.XmlElementAttribute()]
public long s;
}


I think the problem is, in .NET the soapheader must derive from
System.Web.Services.Protocols.SoapHeader . In other words it is a
complexType. In your WSDL you have it as a simpleType. Generating a client
proxy from that WSDL results in some confusion. Feels like a bug in the
wsdl.exe compiler.

The simple fix is to change the definition of the header type in XSD to the
above. This generates what you would expect, I think.

But you have to ensure this synchronizes with the AXIS server. If you are
generating the server from the WSDL then it should be no problem .

-Dino




"Zihong Lu" <(E-Mail Removed)> wrote in message
news:%(E-Mail Removed)...
> Dino,
>
> Thanks. That works.
>
> Now I have a second issue: the soap header. As you can see from my

eariler
> wsdl file, if I do the following:
> (1) changed the line to <element name="getSessionReturn"

type="xsd:string"
> form="qualified"/>, to solve the null result problem;
> (2) uncommented out the line to indicate the soap header in the return
> message:
> <wsdlsoap:header message="impl:soapHeader" part="sessionID" use="literal"
> />
>
> When invoke the getSession() call, the .net client complained:
>
> =========================================
> System.InvalidOperationException: The specified type was not recognized:
> name='long',
> namespace='http://www.w3.org/2001/XMLSchema', at <sessionID
> xmlns='http://xml.apache.org/axis/session'>.
>
> at
>

Microsoft.Xml.Serialization.GeneratedAssembly.XmlS erializationReader1.Read1_
> session(Boolean isNullable, Boolean checkType)
> at
>

Microsoft.Xml.Serialization.GeneratedAssembly.XmlS erializationReader1.Read8_
> OutHeaders()
>
> Do I need to create serializer/deserializer for the SOAP header? I

thought
> the created proxy code already recognize it and can serialize it
> automatically, like gSoap does.
>
> Here is the new generated client proxy:
> ============================
> namespace MyNameSpace{
> using System.Diagnostics;
> using System.Xml.Serialization;
> using System;
> using System.Web.Services.Protocols;
> using System.ComponentModel;
> using System.Web.Services;
>
>
> /// <remarks/>
> [System.Diagnostics.DebuggerStepThroughAttribute()]
> [System.ComponentModel.DesignerCategoryAttribute("c ode")]
>
>

[System.Web.Services.WebServiceBindingAttribute(Nam e="MynameServiceSoapBindi
> ng", Namespace="urn:myname.com")]
> public class MynameServiceService :
> System.Web.Services.Protocols.SoapHttpClientProtoc ol {
>
> public session sessionID;
>
> /// <remarks/>
> public MynameServiceService() {
> this.Url = "http://localhost:8080/services/MynameService";
> }
>
> /// <remarks/>
> [System.Web.Services.Protocols.SoapHeaderAttribute( "sessionID",
> Direction=System.Web.Services.Protocols.SoapHeader Direction.InOut)]
> [System.Web.Services.Protocols.SoapDocumentMethodAt tribute("",
> RequestNamespace="urn:myname.com", ResponseNamespace="urn:myname.com",
> Use=System.Web.Services.Description.SoapBindingUse .Literal,
> ParameterStyle=System.Web.Services.Protocols.SoapP arameterStyle.Wrapped)]
> [return:
> System.Xml.Serialization.XmlElementAttribute("getS essionReturn")]
> public string
>

getSession([System.Xml.Serialization.XmlElementAttribute(Form= System.Xml.Sch
> ema.XmlSchemaForm.Unqualified)] string username,
>

[System.Xml.Serialization.XmlElementAttribute(Form= System.Xml.Schema.XmlSche
> maForm.Unqualified)] string password) {
> object[] results = this.Invoke("getSession", new object[] {
> username,
> password});
> return ((string)(results[0]));
> }
>
> /// <remarks/>
> public System.IAsyncResult BegingetSession(string username, string
> password, System.AsyncCallback callback, object asyncState) {
> return this.BeginInvoke("getSession", new object[] {
> username,
> password}, callback, asyncState);
> }
>
> /// <remarks/>
> public string EndgetSession(System.IAsyncResult asyncResult) {
> object[] results = this.EndInvoke(asyncResult);
> return ((string)(results[0]));
> }
>
> /// <remarks/>
> [System.Web.Services.Protocols.SoapHeaderAttribute( "sessionID",
> Direction=System.Web.Services.Protocols.SoapHeader Direction.InOut)]
> [System.Web.Services.Protocols.SoapDocumentMethodAt tribute("",
> RequestNamespace="urn:myname.com", ResponseNamespace="urn:myname.com",
> Use=System.Web.Services.Description.SoapBindingUse .Literal,
> ParameterStyle=System.Web.Services.Protocols.SoapP arameterStyle.Wrapped)]
> public void closeSession() {
> this.Invoke("closeSession", new object[0]);
> }
>
> /// <remarks/>
> public System.IAsyncResult BegincloseSession(System.AsyncCallback
> callback, object asyncState) {
> return this.BeginInvoke("closeSession", new object[0],

callback,
> asyncState);
> }
>
> /// <remarks/>
> public void EndcloseSession(System.IAsyncResult asyncResult) {
> this.EndInvoke(asyncResult);
> }
> }
>
> /// <remarks/>
>
>

[System.Xml.Serialization.XmlTypeAttribute(Namespac e="http://xml.apache.org/
> axis/session")]
> [System.Xml.Serialization.XmlRootAttribute("session ID",
> Namespace="http://xml.apache.org/axis/session", IsNullable=false)]
> public class session : System.Web.Services.Protocols.SoapHeader {
>
> /// <remarks/>
> [System.Xml.Serialization.XmlTextAttribute()]
> public string[] Text;
> }
> }
>
>
>
>
>
>
>
> "Dino Chiesa [Microsoft]" <(E-Mail Removed)> wrote in message
> news:%(E-Mail Removed)...
> > Yes, A namespace problem .
> > To fix this
> > change the attribute on the getSession() method in the generated client

> side
> > proxy to Qualified, from Unqualified
> >
> > [return:

> System.Xml.Serialization.XmlElementAttribute("getS essionReturn",
> > Form=System.Xml.Schema.XmlSchemaForm.Qualified)]
> >
> > Or, you can modify the WSDL to accurately reflect what AXIS is sending

> back:
> >
> > <element name="getSessionReturn" type="xsd:string" form="qualified" />
> >
> > and then regenerate the client proxy.
> >
> > AXIS is a bit loose with its elementforms (qualified vs unqualified).

The
> > WSDL doesn't specify it, yet the behavior for the request and response

is
> > different.
> > -D
> >
> >
> > "Zihong Lu" <(E-Mail Removed)> wrote in message
> > news:(E-Mail Removed)...
> > > Dino,
> > >
> > > Thank you for looking into this. Yes the request/response messages

are
> > > .net->axis (request) and axis->.net(response).
> > >
> > > Here is the WSDL that I use (Note that I commented out the
> > > <wsdlsoap:header message="impl:soapHeader" part="sessionID"

> > use="literal"/>
> > > for getSession(),
> > > because it is another issue that causing .net confused, it does not

know
> > > what "xsd:long" is.)
> > > ==================================
> > > <?xml version="1.0" encoding="UTF-8" ?>
> > > <wsdl:definitions targetNamespace="urn:myname.com"
> > > xmlns="http://schemas.xmlsoap.org/wsdl/"
> > > xmlns:apachesoap="http://xml.apache.org/xml-soap"
> > > xmlns:impl="urn:myname.com"
> > > xmlns:intf="urn:myname.com"
> > > xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/"
> > > xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
> > > xmlns:wsdlsoap="http://schemas.xmlsoap.org/wsdl/soap/"
> > > xmlnssd="http://www.w3.org/2001/XMLSchema"
> > > xmlns:session="http://xml.apache.org/axis/session">
> > >
> > > <documentation />
> > >
> > > <wsdl:types>
> > >
> > > <schema targetNamespace="http://xml.apache.org/axis/session"
> > > xmlns="http://www.w3.org/2001/XMLSchema">
> > > <simpleType name="session">
> > > <restriction base="xsd:long"/>
> > > </simpleType>
> > > <element name="sessionID" type="session:session"/>
> > > </schema>
> > >
> > > <schema targetNamespace="urn:myname.com"
> > > xmlns="http://www.w3.org/2001/XMLSchema">
> > >
> > >
> > > <element name="getSession">
> > > <complexType>
> > > <sequence>
> > > <element name="username" type="xsd:string" />
> > > <element name="password" type="xsd:string" />
> > > </sequence>
> > > </complexType>
> > > </element>
> > >
> > > <element name="getSessionResponse">
> > > <complexType>
> > > <sequence>
> > > <element name="getSessionReturn" type="xsd:string" />
> > > </sequence>
> > > </complexType>
> > > </element>
> > >
> > > <element name="closeSession">
> > > <complexType />
> > > </element>
> > >
> > > <element name="closeSessionResponse">
> > > <complexType />
> > > </element>
> > >
> > > </schema>
> > > </wsdl:types>
> > >
> > > <wsdl:message name="soapHeader">
> > > <wsdlart name="sessionID" element="session:sessionID" />
> > > </wsdl:message>
> > >
> > > <wsdl:message name="getSessionRequest">
> > > <wsdlart element="impl:getSession" name="parameters" />
> > > </wsdl:message>
> > >
> > > <wsdl:message name="getSessionResponse">
> > > <wsdlart element="impl:getSessionResponse" name="parameters" />
> > > </wsdl:message>
> > >
> > > <wsdl:message name="closeSessionRequest">
> > > <wsdlart element="impl:closeSession" name="parameters" />
> > > </wsdl:message>
> > >
> > > <wsdl:message name="closeSessionResponse">
> > > <wsdlart element="impl:closeSessionResponse" name="parameters"

/>
> > > </wsdl:message>
> > >
> > > <wsdlortType name="MynameService">
> > >
> > > <wsdlperation name="getSession" parameterOrder="">
> > > <wsdl:input message="impl:getSessionRequest"
> > > name="getSessionRequest" />
> > > <wsdlutput message="impl:getSessionResponse"
> > > name="getSessionResponse" />
> > > </wsdlperation>
> > >
> > > <wsdlperation name="closeSession">
> > > <wsdl:input message="impl:closeSessionRequest"
> > > name="closeSessionRequest" />
> > > <wsdlutput message="impl:closeSessionResponse"
> > > name="closeSessionResponse" />
> > > </wsdlperation>
> > >
> > > </wsdlortType>
> > >
> > > <wsdl:binding name="MynameServiceSoapBinding"

type="impl:MynameService">
> > > <wsdlsoap:binding style="document"
> > > transport="http://schemas.xmlsoap.org/soap/http" />
> > >
> > > <wsdlperation name="getSession">
> > > <wsdlsoapperation soapAction="" />
> > > <wsdl:input name="getSessionRequest">
> > > <wsdlsoap:header message="impl:soapHeader"

part="sessionID"
> > > use="literal"/>
> > > <wsdlsoap:body namespace="urn:myname.com" use="literal" />
> > > </wsdl:input>
> > > <wsdlutput name="getSessionResponse">
> > > <!-- comment it out. There is another bug in .net for

> > this -->
> > > <!-- wsdlsoap:header message="impl:soapHeader"

> > part="sessionID"
> > > use="literal"/ -->
> > > <wsdlsoap:body namespace="urn:myname.com" use="literal" />
> > > </wsdlutput>
> > > </wsdlperation>
> > >
> > > <wsdlperation name="closeSession">
> > > <wsdlsoapperation soapAction="" />
> > > <wsdl:input name="closeSessionRequest">
> > > <wsdlsoap:header message="impl:soapHeader"

part="sessionID"
> > > use="literal"/>
> > > <wsdlsoap:body namespace="urn:myname.com" use="literal" />
> > > </wsdl:input>
> > > <wsdlutput name="closeSessionResponse">
> > > <wsdlsoap:header message="impl:soapHeader"

part="sessionID"
> > > use="literal"/>
> > > <wsdlsoap:body namespace="urn:myname.com" use="literal" />
> > > </wsdlutput>
> > > </wsdlperation>
> > >
> > > </wsdl:binding>
> > >
> > > <wsdl:service name="MynameServiceService">
> > > <wsdlort binding="impl:MynameServiceSoapBinding"

> > name="MynameService">
> > > <wsdlsoap:address
> > > location="http://localhost:8080/services/MynameService" />
> > > </wsdlort>
> > > </wsdl:service>
> > >
> > > </wsdl:definitions>
> > >
> > > ============================================
> > >
> > > Generated cs file:
> > > ============================================
> > > namespace MyNameSpace{
> > > using System.Diagnostics;
> > > using System.Xml.Serialization;
> > > using System;
> > > using System.Web.Services.Protocols;
> > > using System.ComponentModel;
> > > using System.Web.Services;
> > >
> > >
> > > /// <remarks/>
> > > [System.Diagnostics.DebuggerStepThroughAttribute()]
> > > [System.ComponentModel.DesignerCategoryAttribute("c ode")]
> > >
> > >

> >

>

[System.Web.Services.WebServiceBindingAttribute(Nam e="MynameServiceSoapBindi
> > > ng", Namespace="urn:myname.com")]
> > > public class MynameServiceService :
> > > System.Web.Services.Protocols.SoapHttpClientProtoc ol {
> > >
> > > public session sessionID;
> > >
> > > /// <remarks/>
> > > public MynameServiceService() {
> > > this.Url = "http://localhost:8080/services/MynameService";
> > > }
> > >
> > > /// <remarks/>
> > >

[System.Web.Services.Protocols.SoapHeaderAttribute( "sessionID")]
> > > [System.Web.Services.Protocols.SoapDocumentMethodAt tribute("",
> > > RequestNamespace="urn:myname.com", ResponseNamespace="urn:myname.com",
> > > Use=System.Web.Services.Description.SoapBindingUse .Literal,
> > >

> ParameterStyle=System.Web.Services.Protocols.SoapP arameterStyle.Wrapped)]
> > > [return:
> > > System.Xml.Serialization.XmlElementAttribute("getS essionReturn",
> > > Form=System.Xml.Schema.XmlSchemaForm.Unqualified)]
> > > public string
> > >

> >

>

getSession([System.Xml.Serialization.XmlElementAttribute(Form= System.Xml.Sch
> > > ema.XmlSchemaForm.Unqualified)] string username,
> > >

> >

>

[System.Xml.Serialization.XmlElementAttribute(Form= System.Xml.Schema.XmlSche
> > > maForm.Unqualified)] string password) {
> > > object[] results = this.Invoke("getSession", new object[]

{
> > > username,
> > > password});
> > > return ((string)(results[0]));
> > > }
> > >
> > > /// <remarks/>
> > > public System.IAsyncResult BegingetSession(string username,

> string
> > > password, System.AsyncCallback callback, object asyncState) {
> > > return this.BeginInvoke("getSession", new object[] {
> > > username,
> > > password}, callback, asyncState);
> > > }
> > >
> > > /// <remarks/>
> > > public string EndgetSession(System.IAsyncResult asyncResult) {
> > > object[] results = this.EndInvoke(asyncResult);
> > > return ((string)(results[0]));
> > > }
> > >
> > > /// <remarks/>
> > >

[System.Web.Services.Protocols.SoapHeaderAttribute( "sessionID",
> > > Direction=System.Web.Services.Protocols.SoapHeader Direction.InOut)]
> > > [System.Web.Services.Protocols.SoapDocumentMethodAt tribute("",
> > > RequestNamespace="urn:myname.com", ResponseNamespace="urn:myname.com",
> > > Use=System.Web.Services.Description.SoapBindingUse .Literal,
> > >

> ParameterStyle=System.Web.Services.Protocols.SoapP arameterStyle.Wrapped)]
> > > public void closeSession() {
> > > this.Invoke("closeSession", new object[0]);
> > > }
> > >
> > > /// <remarks/>
> > > public System.IAsyncResult

> BegincloseSession(System.AsyncCallback
> > > callback, object asyncState) {
> > > return this.BeginInvoke("closeSession", new object[0],

> > callback,
> > > asyncState);
> > > }
> > >
> > > /// <remarks/>
> > > public void EndcloseSession(System.IAsyncResult asyncResult) {
> > > this.EndInvoke(asyncResult);
> > > }
> > > }
> > >
> > > /// <remarks/>
> > >
> > >

> >

>

[System.Xml.Serialization.XmlTypeAttribute(Namespac e="http://xml.apache.org/
> > > axis/session")]
> > > [System.Xml.Serialization.XmlRootAttribute("session ID",
> > > Namespace="http://xml.apache.org/axis/session", IsNullable=false)]
> > > public class session : System.Web.Services.Protocols.SoapHeader {
> > >
> > > /// <remarks/>
> > > [System.Xml.Serialization.XmlTextAttribute()]
> > > public string[] Text;
> > > }
> > > }
> > >
> > > ==================================================
> > >
> > >
> > > "Dino Chiesa [Microsoft]" <(E-Mail Removed)> wrote in

message
> > > news:%(E-Mail Removed)...
> > > > you showed the request and response - I guess that would be a

request
> > from
> > > > .NET to AXIS and a response from AXIS to .NET.
> > > > Can I see the WSDL? or failing that, the client-side proxy

generated
> by
> > > > wsdl.exe ??
> > > >
> > > > I am betting it is an xml namespace issue.
> > > >
> > > > -D
> > > >
> > > > "Zihong Lu" <(E-Mail Removed)> wrote in message
> > > > news:(E-Mail Removed) om...
> > > > > I have used the following settings in our web services:
> > > > >
> > > > > .net framework 1.1 web services client
> > > > > Axis 1.1 server (in wsdd file, set style="wrapped")
> > > > >
> > > > > Using axis client calls the server, it works fine. However, .net
> > > > > client always returns null, even though the soap message has the
> > > > > result, for example, for the simple function
> > > > >
> > > > > string getSession(string username, string password);
> > > > >
> > > > > The SOAP messages in the response seems to be normal, as shown in

> this
> > > > > request/response message:
> > > > >
> > > > > ====== Request ======
> > > > > <?xml version="1.0" encoding="utf-8"?>
> > > > > <soap:Envelope

> xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"
> > > > > xmlnssi="http://www.w3.org/2001/XMLSchema-instance"
> > > > > xmlnssd="http://www.w3.org/2001/XMLSchema">
> > > > > <soap:Body>
> > > > > <getSession xmlns="urn:myname.com">
> > > > > <username xmlns="">admin</username>
> > > > > <password xmlns="" />
> > > > > </getSession>
> > > > > </soap:Body>
> > > > > </soap:Envelope>
> > > > >
> > > > > ====== Response ======
> > > > > 287
> > > > > <?xml version="1.0" encoding="utf-8"?>
> > > > > <soapenv:Envelope
> > > > xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
> > > > > xmlnssd="http://www.w3.org/2001/XMLSchema"
> > > > > xmlnssi="http://www.w3.org/2001/XMLSchema-instance">
> > > > > <soapenv:Header>
> > > > > <ns1:sessionID
> > > > soapenv:actor="http://schemas.xmlsoap.org/soap/actor/next"
> > > > > soapenv:mustUnderstand="0"
> > > > > xmlns:ns1="http://xml.apache.org/axis/session">
> > > > > 7413200230928429396
> > > > > </ns1:sessionID>
> > > > > </soapenv:Header>
> > > > > <soapenv:Body>
> > > > > <getSessionResponse xmlns="urn:myname.com">
> > > > > <getSessionReturn>7413200230928429396</getSessionReturn>
> > > > > </getSessionResponse>
> > > > > </soapenv:Body>
> > > > > </soapenv:Envelope>
> > > > > 0
> > > > >
> > > > >
> > > > > No, I don't know why there is a 287 before <?xml> tag and a 0 at

the
> > > > > end of the response message. This may have something to do with

the
> > > > > response HTTP header
> > > > >
> > > > > Transfer-Encoding: chunked
> > > > >
> > > > > in responding to the .net request HTTP header of "Connection:
> > > > > Keep-Alive".
> > > > >
> > > > > The session ID in SOAP header doesn't seem matter, since I tested

> the
> > > > > call with and without the session ID header. I have serached this
> > > > > group for almost a day, the closest I have found is this link:
> > > > >
> > > > >
> > > >
> > >

> >

>

http://groups.google.com/groups?selm...ing.google.com
> > > > >
> > > > > However, it was talking about serializing complex type there. Can
> > > > > someone plese help?
> > > > >
> > > > >
> > > > > -Zihong
> > > >
> > > >
> > >
> > >

> >
> >

>
>



 
Reply With Quote
 
Zihong Lu
Guest
Posts: n/a
 
      06-21-2004
Dino,

I have changed the session declaration in WSDL to what you suggested, as
showing here:

<schema targetNamespace="http://xml.apache.org/axis/session"
xmlns="http://www.w3.org/2001/XMLSchema">
<element name="sessionID" type="sens:session"/>
<complexType name="session">
<sequence>
<element minOccurs="1" maxOccurs="1" name="id" type="xsd:long"/>
</sequence>
</complexType>
</schema>

where namespace "sens" was defined in the <wsdl:definitions> as
xmlns:sens="http://xml.apache.org/axis/session".

Yes, the generated proxy code now has the same session class derived from
SoapHeader, as earlier. However, compared to the code generated from
simpleType declaration in WSDL earlier , the class memeber "id" now has a
data type of long, instead of the earlier string[], and it has a sensible
name "id" that I set, instead of the earlier generated name of "Text" (these
are the only changes in the whole generated client proxy file):

/// <remarks/>
[System.Xml.Serialization.XmlTypeAttribute(Namespac e="http://xml.apache.org/
axis/session")]
[System.Xml.Serialization.XmlRootAttribute("session ID",
Namespace="http://xml.apache.org/axis/session", IsNullable=false)]
public class session : System.Web.Services.Protocols.SoapHeader {

/// <remarks/>

[System.Xml.Serialization.XmlElementAttribute(Form= System.Xml.Schema.XmlSche
maForm.Unqualified)]
public long id;
}

I have noticed that the "id" is unqulified, while in the example you showed
the "s" does not have the "Unqualified" attribute.

However, even with this change, I still got the same error of
InvalidOperationException. Since the wsdl file is manually edited, I did
not change Axis server side. For the session handling, I simply use
SimpleSessionHandler handler, a convenient handler that Axis provided.

I have also tested the code with the "Form = ... Unqualified" manually
removed from the generated proxy code, I still got the same error. The eror
message is copied here again for completeness:
=======================================
Unhandled Exception: System.InvalidOperationException: There is an error in
XML
document (4, 4). ---> System.InvalidOperationException: The specified type
was n
ot recognized: name='long', namespace='http://www.w3.org/2001/XMLSchema', at
<se
ssionID xmlns='http://xml.apache.org/axis/session'>.
at
Microsoft.Xml.Serialization.GeneratedAssembly.XmlS erializationReader1.Read
1_session(Boolean isNullable, Boolean checkType)
at
Microsoft.Xml.Serialization.GeneratedAssembly.XmlS erializationReader1.Read
8_OutHeaders()
=======================================

The returned SOAP message is
<?xml version="1.0" encoding="UTF-8"?>
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
xmlnssd="http://www.w3.org/2001/XMLSchema"
xmlnssi="http://www.w3.org/2001/XMLSchema-instance">
<soapenv:Header>
<ns1:sessionID soapenv:mustUnderstand="0" xsi:type="xsd:long"
xmlns:ns1="http://xml.apache.org/axis/session">-5227012230670020468</ns1:ses
sionID>
</soapenv:Header>
....

the position (4,4) indicated in the error message is the ns1:sessionID tag.
Does this message looks right to you, compared to what WSDL declared?
Somehow I felt the xsi:type="xsd:long" is not right, since dot/lit style
don't usually have this.

-Zihong



"Dino Chiesa [Microsoft]" <(E-Mail Removed)> wrote in message
news:%(E-Mail Removed)...
> If I modify your WSDL to type the session ID this way:
>
> <element name="sessionID" type="sess:session"/>
>
> <complexType name="session">
> <sequence>
> <element minOccurs="1" maxOccurs="1" name="s"

type="xsd:long"/>
> </sequence>
> </complexType>
>
>
> it works, and generates a header class like so:
>
> public class session : System.Web.Services.Protocols.SoapHeader {
> /// <remarks/>
> [System.Xml.Serialization.XmlElementAttribute()]
> public long s;
> }
>
>
> I think the problem is, in .NET the soapheader must derive from
> System.Web.Services.Protocols.SoapHeader . In other words it is a
> complexType. In your WSDL you have it as a simpleType. Generating a

client
> proxy from that WSDL results in some confusion. Feels like a bug in the
> wsdl.exe compiler.
>
> The simple fix is to change the definition of the header type in XSD to

the
> above. This generates what you would expect, I think.
>
> But you have to ensure this synchronizes with the AXIS server. If you are
> generating the server from the WSDL then it should be no problem .
>
> -Dino
>
>
>
>
> "Zihong Lu" <(E-Mail Removed)> wrote in message
> news:%(E-Mail Removed)...
> > Dino,
> >
> > Thanks. That works.
> >
> > Now I have a second issue: the soap header. As you can see from my

> eariler
> > wsdl file, if I do the following:
> > (1) changed the line to <element name="getSessionReturn"

> type="xsd:string"
> > form="qualified"/>, to solve the null result problem;
> > (2) uncommented out the line to indicate the soap header in the return
> > message:
> > <wsdlsoap:header message="impl:soapHeader" part="sessionID"

use="literal"
> > />
> >
> > When invoke the getSession() call, the .net client complained:
> >
> > =========================================
> > System.InvalidOperationException: The specified type was not recognized:
> > name='long',
> > namespace='http://www.w3.org/2001/XMLSchema', at <sessionID
> > xmlns='http://xml.apache.org/axis/session'>.
> >
> > at
> >

>

Microsoft.Xml.Serialization.GeneratedAssembly.XmlS erializationReader1.Read1_
> > session(Boolean isNullable, Boolean checkType)
> > at
> >

>

Microsoft.Xml.Serialization.GeneratedAssembly.XmlS erializationReader1.Read8_
> > OutHeaders()
> >
> > Do I need to create serializer/deserializer for the SOAP header? I

> thought
> > the created proxy code already recognize it and can serialize it
> > automatically, like gSoap does.
> >
> > Here is the new generated client proxy:
> > ============================
> > namespace MyNameSpace{
> > using System.Diagnostics;
> > using System.Xml.Serialization;
> > using System;
> > using System.Web.Services.Protocols;
> > using System.ComponentModel;
> > using System.Web.Services;
> >
> >
> > /// <remarks/>
> > [System.Diagnostics.DebuggerStepThroughAttribute()]
> > [System.ComponentModel.DesignerCategoryAttribute("c ode")]
> >
> >

>

[System.Web.Services.WebServiceBindingAttribute(Nam e="MynameServiceSoapBindi
> > ng", Namespace="urn:myname.com")]
> > public class MynameServiceService :
> > System.Web.Services.Protocols.SoapHttpClientProtoc ol {
> >
> > public session sessionID;
> >
> > /// <remarks/>
> > public MynameServiceService() {
> > this.Url = "http://localhost:8080/services/MynameService";
> > }
> >
> > /// <remarks/>
> > [System.Web.Services.Protocols.SoapHeaderAttribute( "sessionID",
> > Direction=System.Web.Services.Protocols.SoapHeader Direction.InOut)]
> > [System.Web.Services.Protocols.SoapDocumentMethodAt tribute("",
> > RequestNamespace="urn:myname.com", ResponseNamespace="urn:myname.com",
> > Use=System.Web.Services.Description.SoapBindingUse .Literal,
> >

ParameterStyle=System.Web.Services.Protocols.SoapP arameterStyle.Wrapped)]
> > [return:
> > System.Xml.Serialization.XmlElementAttribute("getS essionReturn")]
> > public string
> >

>

getSession([System.Xml.Serialization.XmlElementAttribute(Form= System.Xml.Sch
> > ema.XmlSchemaForm.Unqualified)] string username,
> >

>

[System.Xml.Serialization.XmlElementAttribute(Form= System.Xml.Schema.XmlSche
> > maForm.Unqualified)] string password) {
> > object[] results = this.Invoke("getSession", new object[] {
> > username,
> > password});
> > return ((string)(results[0]));
> > }
> >
> > /// <remarks/>
> > public System.IAsyncResult BegingetSession(string username,

string
> > password, System.AsyncCallback callback, object asyncState) {
> > return this.BeginInvoke("getSession", new object[] {
> > username,
> > password}, callback, asyncState);
> > }
> >
> > /// <remarks/>
> > public string EndgetSession(System.IAsyncResult asyncResult) {
> > object[] results = this.EndInvoke(asyncResult);
> > return ((string)(results[0]));
> > }
> >
> > /// <remarks/>
> > [System.Web.Services.Protocols.SoapHeaderAttribute( "sessionID",
> > Direction=System.Web.Services.Protocols.SoapHeader Direction.InOut)]
> > [System.Web.Services.Protocols.SoapDocumentMethodAt tribute("",
> > RequestNamespace="urn:myname.com", ResponseNamespace="urn:myname.com",
> > Use=System.Web.Services.Description.SoapBindingUse .Literal,
> >

ParameterStyle=System.Web.Services.Protocols.SoapP arameterStyle.Wrapped)]
> > public void closeSession() {
> > this.Invoke("closeSession", new object[0]);
> > }
> >
> > /// <remarks/>
> > public System.IAsyncResult

BegincloseSession(System.AsyncCallback
> > callback, object asyncState) {
> > return this.BeginInvoke("closeSession", new object[0],

> callback,
> > asyncState);
> > }
> >
> > /// <remarks/>
> > public void EndcloseSession(System.IAsyncResult asyncResult) {
> > this.EndInvoke(asyncResult);
> > }
> > }
> >
> > /// <remarks/>
> >
> >

>

[System.Xml.Serialization.XmlTypeAttribute(Namespac e="http://xml.apache.org/
> > axis/session")]
> > [System.Xml.Serialization.XmlRootAttribute("session ID",
> > Namespace="http://xml.apache.org/axis/session", IsNullable=false)]
> > public class session : System.Web.Services.Protocols.SoapHeader {
> >
> > /// <remarks/>
> > [System.Xml.Serialization.XmlTextAttribute()]
> > public string[] Text;
> > }
> > }
> >
> >
> >
> >
> >
> >
> >



 
Reply With Quote
 
Dino Chiesa [Microsoft]
Guest
Posts: n/a
 
      06-21-2004
yes, I think you are correct. the xsi:type="xsd:long" seems to be
incorrect.

BUT!

We are changing the WSDL here without modifying the server. The WSDL
documents how we would like the service to appear, but if we design the WSDL
independently of the implementation of the service (in AXIS) , then there is
no way of knowing if the two independent things coincide.


It appears that AXIS is using doc/literal for the SOAP body and
soap-section-5 encoded for the SOAP header. Can you check this in the
server/service implementation?

--------------------

It seems like you may be using the AXIS SimpleSessionHandler ? If so,
there are others who have tried to get this to work and had troubles, for
example see the axis user mailing list archive, eg
http://marc.theaimsgroup.com/?l=axis...4009529949&w=2

or
http://marc.theaimsgroup.com/?l=axis...4463001241&w=2

or to search the archive:
http://marc.theaimsgroup.com/?l=axis...ionhandler&q=b


The problem is that AXIS's WSDL2Java tool does not handle soapheaders as
defined in WSDL. If you have a WSDL (such as you have constructed here)
that specifies a soapheader to be used in the input message, the output
message, or both, then the Java implementation generated from AXIS'
"wsdl2java --server-side" does not have any support for that header. As a
developer using AXIS, you need to provide a handler to extract the header,
or insert the header, as appropriate.

The "SimpleSessionHandler" code included with AXIS v1.1 shows this. As you
can see, there is some DOM walking you have to do to extract the header and
de-marshal it and validate it and so on. I suppose there is similar work
you have to do to "add" the header to the response.

But even with all this I am not sure why the header would be section-5
encoded when the body is not. In the WSDL model, the soap body can in
fact be a different "use" than the header. In other words the literal or
section-5 encoded is specified on the body independently from the header.
Eg,

<wsdlutput name="getSessionResponse">
<wsdlsoap:header message="impl:soapHeader" part="sessionID"
use="literal"/>
<wsdlsoap:body namespace="urn:myname.com" use="literal" />
</wsdlutput>



-Dino



"Zihong Lu" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> Dino,
>
> I have changed the session declaration in WSDL to what you suggested, as
> showing here:
>
> <schema targetNamespace="http://xml.apache.org/axis/session"
> xmlns="http://www.w3.org/2001/XMLSchema">
> <element name="sessionID" type="sens:session"/>
> <complexType name="session">
> <sequence>
> <element minOccurs="1" maxOccurs="1" name="id"

type="xsd:long"/>
> </sequence>
> </complexType>
> </schema>
>
> where namespace "sens" was defined in the <wsdl:definitions> as
> xmlns:sens="http://xml.apache.org/axis/session".
>
> Yes, the generated proxy code now has the same session class derived from
> SoapHeader, as earlier. However, compared to the code generated from
> simpleType declaration in WSDL earlier , the class memeber "id" now has a
> data type of long, instead of the earlier string[], and it has a sensible
> name "id" that I set, instead of the earlier generated name of "Text"

(these
> are the only changes in the whole generated client proxy file):
>
> /// <remarks/>
>

[System.Xml.Serialization.XmlTypeAttribute(Namespac e="http://xml.apache.org/
> axis/session")]
> [System.Xml.Serialization.XmlRootAttribute("session ID",
> Namespace="http://xml.apache.org/axis/session", IsNullable=false)]
> public class session : System.Web.Services.Protocols.SoapHeader {
>
> /// <remarks/>
>
>

[System.Xml.Serialization.XmlElementAttribute(Form= System.Xml.Schema.XmlSche
> maForm.Unqualified)]
> public long id;
> }
>
> I have noticed that the "id" is unqulified, while in the example you

showed
> the "s" does not have the "Unqualified" attribute.
>
> However, even with this change, I still got the same error of
> InvalidOperationException. Since the wsdl file is manually edited, I did
> not change Axis server side. For the session handling, I simply use
> SimpleSessionHandler handler, a convenient handler that Axis provided.
>
> I have also tested the code with the "Form = ... Unqualified" manually
> removed from the generated proxy code, I still got the same error. The

eror
> message is copied here again for completeness:
> =======================================
> Unhandled Exception: System.InvalidOperationException: There is an error

in
> XML
> document (4, 4). ---> System.InvalidOperationException: The specified type
> was n
> ot recognized: name='long', namespace='http://www.w3.org/2001/XMLSchema',

at
> <se
> ssionID xmlns='http://xml.apache.org/axis/session'>.
> at
> Microsoft.Xml.Serialization.GeneratedAssembly.XmlS erializationReader1.Read
> 1_session(Boolean isNullable, Boolean checkType)
> at
> Microsoft.Xml.Serialization.GeneratedAssembly.XmlS erializationReader1.Read
> 8_OutHeaders()
> =======================================
>
> The returned SOAP message is
> <?xml version="1.0" encoding="UTF-8"?>
> <soapenv:Envelope

xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
> xmlnssd="http://www.w3.org/2001/XMLSchema"
> xmlnssi="http://www.w3.org/2001/XMLSchema-instance">
> <soapenv:Header>
> <ns1:sessionID soapenv:mustUnderstand="0" xsi:type="xsd:long"
>

xmlns:ns1="http://xml.apache.org/axis/session">-5227012230670020468</ns1:ses
> sionID>
> </soapenv:Header>
> ...
>
> the position (4,4) indicated in the error message is the ns1:sessionID

tag.
> Does this message looks right to you, compared to what WSDL declared?
> Somehow I felt the xsi:type="xsd:long" is not right, since dot/lit style
> don't usually have this.
>
> -Zihong
>
>
>
> "Dino Chiesa [Microsoft]" <(E-Mail Removed)> wrote in message
> news:%(E-Mail Removed)...
> > If I modify your WSDL to type the session ID this way:
> >
> > <element name="sessionID" type="sess:session"/>
> >
> > <complexType name="session">
> > <sequence>
> > <element minOccurs="1" maxOccurs="1" name="s"

> type="xsd:long"/>
> > </sequence>
> > </complexType>
> >
> >
> > it works, and generates a header class like so:
> >
> > public class session : System.Web.Services.Protocols.SoapHeader {
> > /// <remarks/>
> > [System.Xml.Serialization.XmlElementAttribute()]
> > public long s;
> > }
> >
> >
> > I think the problem is, in .NET the soapheader must derive from
> > System.Web.Services.Protocols.SoapHeader . In other words it is a
> > complexType. In your WSDL you have it as a simpleType. Generating a

> client
> > proxy from that WSDL results in some confusion. Feels like a bug in the
> > wsdl.exe compiler.
> >
> > The simple fix is to change the definition of the header type in XSD to

> the
> > above. This generates what you would expect, I think.
> >
> > But you have to ensure this synchronizes with the AXIS server. If you

are
> > generating the server from the WSDL then it should be no problem .
> >
> > -Dino
> >
> >
> >
> >
> > "Zihong Lu" <(E-Mail Removed)> wrote in message
> > news:%(E-Mail Removed)...
> > > Dino,
> > >
> > > Thanks. That works.
> > >
> > > Now I have a second issue: the soap header. As you can see from my

> > eariler
> > > wsdl file, if I do the following:
> > > (1) changed the line to <element name="getSessionReturn"

> > type="xsd:string"
> > > form="qualified"/>, to solve the null result problem;
> > > (2) uncommented out the line to indicate the soap header in the return
> > > message:
> > > <wsdlsoap:header message="impl:soapHeader" part="sessionID"

> use="literal"
> > > />
> > >
> > > When invoke the getSession() call, the .net client complained:
> > >
> > > =========================================
> > > System.InvalidOperationException: The specified type was not

recognized:
> > > name='long',
> > > namespace='http://www.w3.org/2001/XMLSchema', at <sessionID
> > > xmlns='http://xml.apache.org/axis/session'>.
> > >
> > > at
> > >

> >

>

Microsoft.Xml.Serialization.GeneratedAssembly.XmlS erializationReader1.Read1_
> > > session(Boolean isNullable, Boolean checkType)
> > > at
> > >

> >

>

Microsoft.Xml.Serialization.GeneratedAssembly.XmlS erializationReader1.Read8_
> > > OutHeaders()
> > >
> > > Do I need to create serializer/deserializer for the SOAP header? I

> > thought
> > > the created proxy code already recognize it and can serialize it
> > > automatically, like gSoap does.
> > >
> > > Here is the new generated client proxy:
> > > ============================
> > > namespace MyNameSpace{
> > > using System.Diagnostics;
> > > using System.Xml.Serialization;
> > > using System;
> > > using System.Web.Services.Protocols;
> > > using System.ComponentModel;
> > > using System.Web.Services;
> > >
> > >
> > > /// <remarks/>
> > > [System.Diagnostics.DebuggerStepThroughAttribute()]
> > > [System.ComponentModel.DesignerCategoryAttribute("c ode")]
> > >
> > >

> >

>

[System.Web.Services.WebServiceBindingAttribute(Nam e="MynameServiceSoapBindi
> > > ng", Namespace="urn:myname.com")]
> > > public class MynameServiceService :
> > > System.Web.Services.Protocols.SoapHttpClientProtoc ol {
> > >
> > > public session sessionID;
> > >
> > > /// <remarks/>
> > > public MynameServiceService() {
> > > this.Url = "http://localhost:8080/services/MynameService";
> > > }
> > >
> > > /// <remarks/>
> > >

[System.Web.Services.Protocols.SoapHeaderAttribute( "sessionID",
> > > Direction=System.Web.Services.Protocols.SoapHeader Direction.InOut)]
> > > [System.Web.Services.Protocols.SoapDocumentMethodAt tribute("",
> > > RequestNamespace="urn:myname.com", ResponseNamespace="urn:myname.com",
> > > Use=System.Web.Services.Description.SoapBindingUse .Literal,
> > >

> ParameterStyle=System.Web.Services.Protocols.SoapP arameterStyle.Wrapped)]
> > > [return:
> > > System.Xml.Serialization.XmlElementAttribute("getS essionReturn")]
> > > public string
> > >

> >

>

getSession([System.Xml.Serialization.XmlElementAttribute(Form= System.Xml.Sch
> > > ema.XmlSchemaForm.Unqualified)] string username,
> > >

> >

>

[System.Xml.Serialization.XmlElementAttribute(Form= System.Xml.Schema.XmlSche
> > > maForm.Unqualified)] string password) {
> > > object[] results = this.Invoke("getSession", new object[]

{
> > > username,
> > > password});
> > > return ((string)(results[0]));
> > > }
> > >
> > > /// <remarks/>
> > > public System.IAsyncResult BegingetSession(string username,

> string
> > > password, System.AsyncCallback callback, object asyncState) {
> > > return this.BeginInvoke("getSession", new object[] {
> > > username,
> > > password}, callback, asyncState);
> > > }
> > >
> > > /// <remarks/>
> > > public string EndgetSession(System.IAsyncResult asyncResult) {
> > > object[] results = this.EndInvoke(asyncResult);
> > > return ((string)(results[0]));
> > > }
> > >
> > > /// <remarks/>
> > >

[System.Web.Services.Protocols.SoapHeaderAttribute( "sessionID",
> > > Direction=System.Web.Services.Protocols.SoapHeader Direction.InOut)]
> > > [System.Web.Services.Protocols.SoapDocumentMethodAt tribute("",
> > > RequestNamespace="urn:myname.com", ResponseNamespace="urn:myname.com",
> > > Use=System.Web.Services.Description.SoapBindingUse .Literal,
> > >

> ParameterStyle=System.Web.Services.Protocols.SoapP arameterStyle.Wrapped)]
> > > public void closeSession() {
> > > this.Invoke("closeSession", new object[0]);
> > > }
> > >
> > > /// <remarks/>
> > > public System.IAsyncResult

> BegincloseSession(System.AsyncCallback
> > > callback, object asyncState) {
> > > return this.BeginInvoke("closeSession", new object[0],

> > callback,
> > > asyncState);
> > > }
> > >
> > > /// <remarks/>
> > > public void EndcloseSession(System.IAsyncResult asyncResult) {
> > > this.EndInvoke(asyncResult);
> > > }
> > > }
> > >
> > > /// <remarks/>
> > >
> > >

> >

>

[System.Xml.Serialization.XmlTypeAttribute(Namespac e="http://xml.apache.org/
> > > axis/session")]
> > > [System.Xml.Serialization.XmlRootAttribute("session ID",
> > > Namespace="http://xml.apache.org/axis/session", IsNullable=false)]
> > > public class session : System.Web.Services.Protocols.SoapHeader {
> > >
> > > /// <remarks/>
> > > [System.Xml.Serialization.XmlTextAttribute()]
> > > public string[] Text;
> > > }
> > > }
> > >
> > >
> > >
> > >
> > >
> > >
> > >

>
>



 
Reply With Quote
 
Zihong Lu
Guest
Posts: n/a
 
      06-22-2004
Dino,

Yes I did search the axis-users group for days before I came to asking for
help in this group. For some reason the solution they provide there don't
work for me.

You are right that from axis server side, I need to hand craft the skeleton
codes/settings before I can use the session handler, and I did manage to
overcome the problem on that side.

Back to the issue here. I have been experimenting further, by modifying the
wsdl file namespace. Then, magically, the getSession() function call
succeeded. From that point view, the xsi:type may not be an issue.

But, problems are not finished yet, the subsequent call closeSession() from
the .bet client does not have the sessionID included in the header. This is
the .net->axis request for closeSession() after the getSession() call:

<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"
xmlnssi="http://www.w3.org/2001/XMLSchema-instance"
xmlnssd="http://www.w3.org/2001/XMLSchema">
<soap:Body>
<closeSession xmlns="urn:myname.com" />
</soap:Body>
</soap:Envelope>

Any idea?


Here is the modified WSDL:
========================================
<?xml version="1.0" encoding="UTF-8" ?>
<wsdl:definitions targetNamespace="urn:myname.com"
xmlns="http://schemas.xmlsoap.org/wsdl/"
xmlns:apachesoap="http://xml.apache.org/xml-soap"
xmlns:impl="urn:myname.com"
xmlns:intf="urn:myname.com"
xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/"
xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
xmlns:wsdlsoap="http://schemas.xmlsoap.org/wsdl/soap/"
xmlnssd="http://www.w3.org/2001/XMLSchema"
xmlns:sens="http://xml.apache.org/axis/session">

<wsdl:types>

<schema targetNamespace="urn:myname.com"
xmlns="http://www.w3.org/2001/XMLSchema">

<element name="sessionID" type="impl:session" />
<complexType name="session">
<sequence>
<element minOccurs="1" maxOccurs="1" name="id" type="xsd:long" />
</sequence>
</complexType>

<element name="getSession">
<complexType>
<sequence>
<element name="username" type="xsd:string" />
<element name="password" type="xsd:string" />
</sequence>
</complexType>
</element>

<element name="getSessionResponse">
<complexType>
<sequence>
<element name="getSessionReturn" type="xsd:string"
form="qualified" />
</sequence>
</complexType>
</element>

<element name="closeSession">
<complexType />
</element>

<element name="closeSessionResponse">
<complexType />
</element>

</schema>
</wsdl:types>

<wsdl:message name="soapHeader">
<wsdlart name="sessionID" element="impl:sessionID" />
</wsdl:message>

<wsdl:message name="getSessionRequest">
<wsdlart element="impl:getSession" name="parameters" />
</wsdl:message>

<wsdl:message name="getSessionResponse">
<wsdlart element="impl:getSessionResponse" name="parameters" />
</wsdl:message>

<wsdl:message name="closeSessionRequest">
<wsdlart element="impl:closeSession" name="parameters" />
</wsdl:message>

<wsdl:message name="closeSessionResponse">
<wsdlart element="impl:closeSessionResponse" name="parameters" />
</wsdl:message>

<wsdlortType name="MynameService">

<wsdlperation name="getSession" parameterOrder="">
<wsdl:input message="impl:getSessionRequest"
name="getSessionRequest" />
<wsdlutput message="impl:getSessionResponse"
name="getSessionResponse" />
</wsdlperation>

<wsdlperation name="closeSession">
<wsdl:input message="impl:closeSessionRequest"
name="closeSessionRequest" />
<wsdlutput message="impl:closeSessionResponse"
name="closeSessionResponse" />
</wsdlperation>

</wsdlortType>


<wsdl:binding name="MynameServiceSoapBinding" type="impl:MynameService">
<wsdlsoap:binding style="document"
transport="http://schemas.xmlsoap.org/soap/http" />

<wsdlperation name="getSession">
<wsdlsoapperation soapAction="" />
<wsdl:input name="getSessionRequest">
<wsdlsoap:header message="impl:soapHeader" part="sessionID"
use="literal"/>
<wsdlsoap:body namespace="urn:myname.com" use="literal" />
</wsdl:input>
<wsdlutput name="getSessionResponse">
<wsdlsoap:header message="impl:soapHeader" part="sessionID"
use="literal"/>
<wsdlsoap:body namespace="urn:myname.com" use="literal" />
</wsdlutput>
</wsdlperation>

<wsdlperation name="closeSession">
<wsdlsoapperation soapAction="" />
<wsdl:input name="closeSessionRequest">
<wsdlsoap:header message="impl:soapHeader" part="sessionID"
use="literal"/>
<wsdlsoap:body namespace="urn:myname.com" use="literal" />
</wsdl:input>
<wsdlutput name="closeSessionResponse">
<wsdlsoap:header message="impl:soapHeader" part="sessionID"
use="literal"/>
<wsdlsoap:body namespace="urn:myname.com" use="literal" />
</wsdlutput>
</wsdlperation>

</wsdl:binding>

<wsdl:service name="MynameServiceService">
<wsdlort binding="impl:MynameServiceSoapBinding" name="MynameService">
<wsdlsoap:address
location="http://localhost:8080/services/MynameService" />
</wsdlort>
</wsdl:service>

</wsdl:definitions>
====================================

This is the created client proxy:

namespace MyNameSpace{

using System.Diagnostics;

using System.Xml.Serialization;

using System;

using System.Web.Services.Protocols;

using System.ComponentModel;

using System.Web.Services;



/// <remarks/>

[System.Diagnostics.DebuggerStepThroughAttribute()]

[System.ComponentModel.DesignerCategoryAttribute("c ode")]

[System.Web.Services.WebServiceBindingAttribute(Nam e="MynameServiceSoapBindi
ng", Namespace="urn:myname.com")]

public class MynameServiceService :
System.Web.Services.Protocols.SoapHttpClientProtoc ol {


public session sessionID;


/// <remarks/>

public MynameServiceService() {

this.Url = "http://localhost:8080/services/MynameService";

}


/// <remarks/>

[System.Web.Services.Protocols.SoapHeaderAttribute( "sessionID",
Direction=System.Web.Services.Protocols.SoapHeader Direction.InOut)]

[System.Web.Services.Protocols.SoapDocumentMethodAt tribute("",
RequestNamespace="urn:myname.com", ResponseNamespace="urn:myname.com",
Use=System.Web.Services.Description.SoapBindingUse .Literal,
ParameterStyle=System.Web.Services.Protocols.SoapP arameterStyle.Wrapped)]

[return: System.Xml.Serialization.XmlElementAttribute("getS essionReturn")]

public string
getSession([System.Xml.Serialization.XmlElementdttribute(Form= System.Xml.Sch
ema.XmlSchemaForm.Unqualified)] string username,
[System.Xml.Serialization.XmlElementAttribute(Form= System.Xml.Schema.XmlSche
maForm.Unqualified)] string password) {

object[] results = this.Invoke("getSession", new object[] {

username,

password});

return ((string)(results[0]));

}


/// <remarks/>

public System.IAsyncResult BegingetSession(string username, string password,
System.AsyncCallback callback, object asyncState) {

return this.BeginInvoke("getSession", new object[] {

username,

password}, callback, asyncState);

}


/// <remarks/>

public string EndgetSession(System.IAsyncResult asyncResult) {

object[] results = this.EndInvoke(asyncResult);

return ((string)(results[0]));

}


/// <remarks/>

[System.Web.Services.Protocols.SoapHeaderAttribute( "sessionID",
Direction=System.Web.Services.Protocols.SoapHeader Direction.InOut)]

[System.Web.Services.Protocols.SoapDocumentMethodAt tribute("",
RequestNamespace="urn:myname.com", ResponseNamespace="urn:myname.com",
Use=System.Web.Services.Description.SoapBindingUse .Literal,
ParameterStyle=System.Web.Services.Protocols.SoapP arameterStyle.Wrapped)]

public void closeSession() {

this.Invoke("closeSession", new object[0]);

}


/// <remarks/>

public System.IAsyncResult BegincloseSession(System.AsyncCallback callback,
object asyncState) {

return this.BeginInvoke("closeSession", new object[0], callback,
asyncState);

}


/// <remarks/>

public void EndcloseSession(System.IAsyncResult asyncResult) {

this.EndInvoke(asyncResult);

}

}


/// <remarks/>

[System.Xml.Serialization.XmlTypeAttribute(Namespac e="urn:myname.com")]

[System.Xml.Serialization.XmlRootAttribute("session ID",
Namespace="urn:myname.com", IsNullable=false)]

public class session : System.Web.Services.Protocols.SoapHeader {


/// <remarks/>

[System.Xml.Serialization.XmlElementAttribute(Form= System.Xml.Schema.XmlSche
maForm.Unqualified)]

public long id;

}

}






"Dino Chiesa [Microsoft]" <(E-Mail Removed)> wrote in message
news:%(E-Mail Removed)...
> yes, I think you are correct. the xsi:type="xsd:long" seems to be
> incorrect.
>
> BUT!
>
> We are changing the WSDL here without modifying the server. The WSDL
> documents how we would like the service to appear, but if we design the

WSDL
> independently of the implementation of the service (in AXIS) , then there

is
> no way of knowing if the two independent things coincide.
>
>
> It appears that AXIS is using doc/literal for the SOAP body and
> soap-section-5 encoded for the SOAP header. Can you check this in the
> server/service implementation?
>
> --------------------
>
> It seems like you may be using the AXIS SimpleSessionHandler ? If so,
> there are others who have tried to get this to work and had troubles, for
> example see the axis user mailing list archive, eg
> http://marc.theaimsgroup.com/?l=axis...4009529949&w=2
>
> or
> http://marc.theaimsgroup.com/?l=axis...4463001241&w=2
>
> or to search the archive:
> http://marc.theaimsgroup.com/?l=axis...ionhandler&q=b
>
>
> The problem is that AXIS's WSDL2Java tool does not handle soapheaders as
> defined in WSDL. If you have a WSDL (such as you have constructed here)
> that specifies a soapheader to be used in the input message, the output
> message, or both, then the Java implementation generated from AXIS'
> "wsdl2java --server-side" does not have any support for that header. As a
> developer using AXIS, you need to provide a handler to extract the

header,
> or insert the header, as appropriate.
>
> The "SimpleSessionHandler" code included with AXIS v1.1 shows this. As

you
> can see, there is some DOM walking you have to do to extract the header

and
> de-marshal it and validate it and so on. I suppose there is similar work
> you have to do to "add" the header to the response.
>
> But even with all this I am not sure why the header would be section-5
> encoded when the body is not. In the WSDL model, the soap body can in
> fact be a different "use" than the header. In other words the literal or
> section-5 encoded is specified on the body independently from the header.
> Eg,
>
> <wsdlutput name="getSessionResponse">
> <wsdlsoap:header message="impl:soapHeader" part="sessionID"
> use="literal"/>
> <wsdlsoap:body namespace="urn:myname.com" use="literal" />
> </wsdlutput>
>
>
>
> -Dino
>
>
>
> "Zihong Lu" <(E-Mail Removed)> wrote in message
> news:(E-Mail Removed)...
> > Dino,
> >
> > I have changed the session declaration in WSDL to what you suggested,

as
> > showing here:
> >
> > <schema targetNamespace="http://xml.apache.org/axis/session"
> > xmlns="http://www.w3.org/2001/XMLSchema">
> > <element name="sessionID" type="sens:session"/>
> > <complexType name="session">
> > <sequence>
> > <element minOccurs="1" maxOccurs="1" name="id"

> type="xsd:long"/>
> > </sequence>
> > </complexType>
> > </schema>
> >
> > where namespace "sens" was defined in the <wsdl:definitions> as
> > xmlns:sens="http://xml.apache.org/axis/session".
> >
> > Yes, the generated proxy code now has the same session class derived

from
> > SoapHeader, as earlier. However, compared to the code generated from
> > simpleType declaration in WSDL earlier , the class memeber "id" now has

a
> > data type of long, instead of the earlier string[], and it has a

sensible
> > name "id" that I set, instead of the earlier generated name of "Text"

> (these
> > are the only changes in the whole generated client proxy file):
> >
> > /// <remarks/>
> >

>

[System.Xml.Serialization.XmlTypeAttribute(Namespac e="http://xml.apache.org/
> > axis/session")]
> > [System.Xml.Serialization.XmlRootAttribute("session ID",
> > Namespace="http://xml.apache.org/axis/session", IsNullable=false)]
> > public class session : System.Web.Services.Protocols.SoapHeader {
> >
> > /// <remarks/>
> >
> >

>

[System.Xml.Serialization.XmlElementAttribute(Form= System.Xml.Schema.XmlSche
> > maForm.Unqualified)]
> > public long id;
> > }
> >
> > I have noticed that the "id" is unqulified, while in the example you

> showed
> > the "s" does not have the "Unqualified" attribute.
> >
> > However, even with this change, I still got the same error of
> > InvalidOperationException. Since the wsdl file is manually edited, I

did
> > not change Axis server side. For the session handling, I simply use
> > SimpleSessionHandler handler, a convenient handler that Axis provided.
> >
> > I have also tested the code with the "Form = ... Unqualified" manually
> > removed from the generated proxy code, I still got the same error. The

> eror
> > message is copied here again for completeness:
> > =======================================
> > Unhandled Exception: System.InvalidOperationException: There is an error

> in
> > XML
> > document (4, 4). ---> System.InvalidOperationException: The specified

type
> > was n
> > ot recognized: name='long',

namespace='http://www.w3.org/2001/XMLSchema',
> at
> > <se
> > ssionID xmlns='http://xml.apache.org/axis/session'>.
> > at
> >

Microsoft.Xml.Serialization.GeneratedAssembly.XmlS erializationReader1.Read
> > 1_session(Boolean isNullable, Boolean checkType)
> > at
> >

Microsoft.Xml.Serialization.GeneratedAssembly.XmlS erializationReader1.Read
> > 8_OutHeaders()
> > =======================================
> >
> > The returned SOAP message is
> > <?xml version="1.0" encoding="UTF-8"?>
> > <soapenv:Envelope

> xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
> > xmlnssd="http://www.w3.org/2001/XMLSchema"
> > xmlnssi="http://www.w3.org/2001/XMLSchema-instance">
> > <soapenv:Header>
> > <ns1:sessionID soapenv:mustUnderstand="0" xsi:type="xsd:long"
> >

>

xmlns:ns1="http://xml.apache.org/axis/session">-5227012230670020468</ns1:ses
> > sionID>
> > </soapenv:Header>
> > ...
> >
> > the position (4,4) indicated in the error message is the ns1:sessionID

> tag.
> > Does this message looks right to you, compared to what WSDL declared?
> > Somehow I felt the xsi:type="xsd:long" is not right, since dot/lit style
> > don't usually have this.
> >
> > -Zihong
> >
> >
> >
> > "Dino Chiesa [Microsoft]" <(E-Mail Removed)> wrote in message
> > news:%(E-Mail Removed)...
> > > If I modify your WSDL to type the session ID this way:
> > >
> > > <element name="sessionID" type="sess:session"/>
> > >
> > > <complexType name="session">
> > > <sequence>
> > > <element minOccurs="1" maxOccurs="1" name="s"

> > type="xsd:long"/>
> > > </sequence>
> > > </complexType>
> > >
> > >
> > > it works, and generates a header class like so:
> > >
> > > public class session : System.Web.Services.Protocols.SoapHeader {
> > > /// <remarks/>
> > > [System.Xml.Serialization.XmlElementAttribute()]
> > > public long s;
> > > }
> > >
> > >
> > > I think the problem is, in .NET the soapheader must derive from
> > > System.Web.Services.Protocols.SoapHeader . In other words it is a
> > > complexType. In your WSDL you have it as a simpleType. Generating a

> > client
> > > proxy from that WSDL results in some confusion. Feels like a bug in

the
> > > wsdl.exe compiler.
> > >
> > > The simple fix is to change the definition of the header type in XSD

to
> > the
> > > above. This generates what you would expect, I think.
> > >
> > > But you have to ensure this synchronizes with the AXIS server. If you

> are
> > > generating the server from the WSDL then it should be no problem .
> > >
> > > -Dino
> > >
> > >
> > >
> > >
> > > "Zihong Lu" <(E-Mail Removed)> wrote in message
> > > news:%(E-Mail Removed)...
> > > > Dino,
> > > >
> > > > Thanks. That works.
> > > >
> > > > Now I have a second issue: the soap header. As you can see from my
> > > eariler
> > > > wsdl file, if I do the following:
> > > > (1) changed the line to <element name="getSessionReturn"
> > > type="xsd:string"
> > > > form="qualified"/>, to solve the null result problem;
> > > > (2) uncommented out the line to indicate the soap header in the

return
> > > > message:
> > > > <wsdlsoap:header message="impl:soapHeader" part="sessionID"

> > use="literal"
> > > > />
> > > >
> > > > When invoke the getSession() call, the .net client complained:
> > > >
> > > > =========================================
> > > > System.InvalidOperationException: The specified type was not

> recognized:
> > > > name='long',
> > > > namespace='http://www.w3.org/2001/XMLSchema', at <sessionID
> > > > xmlns='http://xml.apache.org/axis/session'>.
> > > >
> > > > at
> > > >
> > >

> >

>

Microsoft.Xml.Serialization.GeneratedAssembly.XmlS erializationReader1.Read1_
> > > > session(Boolean isNullable, Boolean checkType)
> > > > at
> > > >
> > >

> >

>

Microsoft.Xml.Serialization.GeneratedAssembly.XmlS erializationReader1.Read8_
> > > > OutHeaders()
> > > >
> > > > Do I need to create serializer/deserializer for the SOAP header? I
> > > thought
> > > > the created proxy code already recognize it and can serialize it
> > > > automatically, like gSoap does.
> > > >
> > > > Here is the new generated client proxy:
> > > > ============================
> > > > namespace MyNameSpace{
> > > > using System.Diagnostics;
> > > > using System.Xml.Serialization;
> > > > using System;
> > > > using System.Web.Services.Protocols;
> > > > using System.ComponentModel;
> > > > using System.Web.Services;
> > > >
> > > >
> > > > /// <remarks/>
> > > > [System.Diagnostics.DebuggerStepThroughAttribute()]
> > > > [System.ComponentModel.DesignerCategoryAttribute("c ode")]
> > > >
> > > >
> > >

> >

>

[System.Web.Services.WebServiceBindingAttribute(Nam e="MynameServiceSoapBindi
> > > > ng", Namespace="urn:myname.com")]
> > > > public class MynameServiceService :
> > > > System.Web.Services.Protocols.SoapHttpClientProtoc ol {
> > > >
> > > > public session sessionID;
> > > >
> > > > /// <remarks/>
> > > > public MynameServiceService() {
> > > > this.Url =

"http://localhost:8080/services/MynameService";
> > > > }
> > > >
> > > > /// <remarks/>
> > > >

> [System.Web.Services.Protocols.SoapHeaderAttribute( "sessionID",
> > > > Direction=System.Web.Services.Protocols.SoapHeader Direction.InOut)]
> > > >

[System.Web.Services.Protocols.SoapDocumentMethodAt tribute("",
> > > > RequestNamespace="urn:myname.com",

ResponseNamespace="urn:myname.com",
> > > > Use=System.Web.Services.Description.SoapBindingUse .Literal,
> > > >

> >

ParameterStyle=System.Web.Services.Protocols.SoapP arameterStyle.Wrapped)]
> > > > [return:
> > > > System.Xml.Serialization.XmlElementAttribute("getS essionReturn")]
> > > > public string
> > > >
> > >

> >

>

getSession([System.Xml.Serialization.XmlElementAttribute(Form= System.Xml.Sch
> > > > ema.XmlSchemaForm.Unqualified)] string username,
> > > >
> > >

> >

>

[System.Xml.Serialization.XmlElementAttribute(Form= System.Xml.Schema.XmlSche
> > > > maForm.Unqualified)] string password) {
> > > > object[] results = this.Invoke("getSession", new

object[]
> {
> > > > username,
> > > > password});
> > > > return ((string)(results[0]));
> > > > }
> > > >
> > > > /// <remarks/>
> > > > public System.IAsyncResult BegingetSession(string username,

> > string
> > > > password, System.AsyncCallback callback, object asyncState) {
> > > > return this.BeginInvoke("getSession", new object[] {
> > > > username,
> > > > password}, callback, asyncState);
> > > > }
> > > >
> > > > /// <remarks/>
> > > > public string EndgetSession(System.IAsyncResult asyncResult)

{
> > > > object[] results = this.EndInvoke(asyncResult);
> > > > return ((string)(results[0]));
> > > > }
> > > >
> > > > /// <remarks/>
> > > >

> [System.Web.Services.Protocols.SoapHeaderAttribute( "sessionID",
> > > > Direction=System.Web.Services.Protocols.SoapHeader Direction.InOut)]
> > > >

[System.Web.Services.Protocols.SoapDocumentMethodAt tribute("",
> > > > RequestNamespace="urn:myname.com",

ResponseNamespace="urn:myname.com",
> > > > Use=System.Web.Services.Description.SoapBindingUse .Literal,
> > > >

> >

ParameterStyle=System.Web.Services.Protocols.SoapP arameterStyle.Wrapped)]
> > > > public void closeSession() {
> > > > this.Invoke("closeSession", new object[0]);
> > > > }
> > > >
> > > > /// <remarks/>
> > > > public System.IAsyncResult

> > BegincloseSession(System.AsyncCallback
> > > > callback, object asyncState) {
> > > > return this.BeginInvoke("closeSession", new object[0],
> > > callback,
> > > > asyncState);
> > > > }
> > > >
> > > > /// <remarks/>
> > > > public void EndcloseSession(System.IAsyncResult asyncResult)

{
> > > > this.EndInvoke(asyncResult);
> > > > }
> > > > }
> > > >
> > > > /// <remarks/>
> > > >
> > > >
> > >

> >

>

[System.Xml.Serialization.XmlTypeAttribute(Namespac e="http://xml.apache.org/
> > > > axis/session")]
> > > > [System.Xml.Serialization.XmlRootAttribute("session ID",
> > > > Namespace="http://xml.apache.org/axis/session", IsNullable=false)]
> > > > public class session : System.Web.Services.Protocols.SoapHeader

{
> > > >
> > > > /// <remarks/>
> > > > [System.Xml.Serialization.XmlTextAttribute()]
> > > > public string[] Text;
> > > > }
> > > > }
> > > >
> > > >
> > > >
> > > >
> > > >
> > > >
> > > >

> >
> >

>
>



 
Reply With Quote
 
Zihong Lu
Guest
Posts: n/a
 
      06-22-2004
I believe my approach is wrong. Because the element type "sessionID" is
defined in the "impl" namespace, ie, the urn:myname.com namespace, which
means that upon return in getSession() call, the .net client will look for
the sessionID in the urn:myname.com namespace. However, in the return
message, axis sends the header in the http://xml.apache.org/axis/session
namespace, as shown here for axis->.net response to getSession():

<?xml version="1.0" encoding="UTF-8"?>
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
xmlnssd="http://www.w3.org/1999/XMLSchema"
xmlnssi="http://www.w3.org/1999/XMLSchema-instance">
<soapenv:Header>
<ns2:sessionID soapenv:mustUnderstand="0" xsi:type="ns1:long"
xmlnssi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:ns1="http://www.w3.org/2001/XMLSchema"

xmlns:ns2="http://xml.apache.org/axis/session">-3876663609367995448</ns2:ses
sionID>
</soapenv:Header>
<soapenv:Body>
<getSessionResponse xmlns="urn:myname.com">
<getSessionReturn>-3876663609367995448</getSessionReturn>
</getSessionResponse>
</soapenv:Body>
</soapenv:Envelope>


since .net did not find anything in the urn:myname.com namespace, it simply
ignore the header, hence the getSession() call returned nicely, no error.
However, it did not get the session ID in the header either, hence, no
session ID in the subsequent closeSession() call.

Well, back to the same problem.

-Zihong

"Zihong Lu" <(E-Mail Removed)> wrote in message
news:ODrL7l$(E-Mail Removed)...
> Dino,
>
> Yes I did search the axis-users group for days before I came to asking for
> help in this group. For some reason the solution they provide there don't
> work for me.
>
> You are right that from axis server side, I need to hand craft the

skeleton
> codes/settings before I can use the session handler, and I did manage to
> overcome the problem on that side.
>
> Back to the issue here. I have been experimenting further, by modifying

the
> wsdl file namespace. Then, magically, the getSession() function call
> succeeded. From that point view, the xsi:type may not be an issue.
>
> But, problems are not finished yet, the subsequent call closeSession()

from
> the .bet client does not have the sessionID included in the header. This

is
> the .net->axis request for closeSession() after the getSession() call:
>
> <?xml version="1.0" encoding="utf-8"?>
> <soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"
> xmlnssi="http://www.w3.org/2001/XMLSchema-instance"
> xmlnssd="http://www.w3.org/2001/XMLSchema">
> <soap:Body>
> <closeSession xmlns="urn:myname.com" />
> </soap:Body>
> </soap:Envelope>
>
> Any idea?
>
>
> Here is the modified WSDL:
> ========================================
> <?xml version="1.0" encoding="UTF-8" ?>
> <wsdl:definitions targetNamespace="urn:myname.com"
> xmlns="http://schemas.xmlsoap.org/wsdl/"
> xmlns:apachesoap="http://xml.apache.org/xml-soap"
> xmlns:impl="urn:myname.com"
> xmlns:intf="urn:myname.com"
> xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/"
> xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
> xmlns:wsdlsoap="http://schemas.xmlsoap.org/wsdl/soap/"
> xmlnssd="http://www.w3.org/2001/XMLSchema"
> xmlns:sens="http://xml.apache.org/axis/session">
>
> <wsdl:types>
>
> <schema targetNamespace="urn:myname.com"
> xmlns="http://www.w3.org/2001/XMLSchema">
>
> <element name="sessionID" type="impl:session" />
> <complexType name="session">
> <sequence>
> <element minOccurs="1" maxOccurs="1" name="id" type="xsd:long" />
> </sequence>
> </complexType>
>
> <element name="getSession">
> <complexType>
> <sequence>
> <element name="username" type="xsd:string" />
> <element name="password" type="xsd:string" />
> </sequence>
> </complexType>
> </element>
>
> <element name="getSessionResponse">
> <complexType>
> <sequence>
> <element name="getSessionReturn" type="xsd:string"
> form="qualified" />
> </sequence>
> </complexType>
> </element>
>
> <element name="closeSession">
> <complexType />
> </element>
>
> <element name="closeSessionResponse">
> <complexType />
> </element>
>
> </schema>
> </wsdl:types>
>
> <wsdl:message name="soapHeader">
> <wsdlart name="sessionID" element="impl:sessionID" />
> </wsdl:message>
>
> <wsdl:message name="getSessionRequest">
> <wsdlart element="impl:getSession" name="parameters" />
> </wsdl:message>
>
> <wsdl:message name="getSessionResponse">
> <wsdlart element="impl:getSessionResponse" name="parameters" />
> </wsdl:message>
>
> <wsdl:message name="closeSessionRequest">
> <wsdlart element="impl:closeSession" name="parameters" />
> </wsdl:message>
>
> <wsdl:message name="closeSessionResponse">
> <wsdlart element="impl:closeSessionResponse" name="parameters" />
> </wsdl:message>
>
> <wsdlortType name="MynameService">
>
> <wsdlperation name="getSession" parameterOrder="">
> <wsdl:input message="impl:getSessionRequest"
> name="getSessionRequest" />
> <wsdlutput message="impl:getSessionResponse"
> name="getSessionResponse" />
> </wsdlperation>
>
> <wsdlperation name="closeSession">
> <wsdl:input message="impl:closeSessionRequest"
> name="closeSessionRequest" />
> <wsdlutput message="impl:closeSessionResponse"
> name="closeSessionResponse" />
> </wsdlperation>
>
> </wsdlortType>
>
>
> <wsdl:binding name="MynameServiceSoapBinding" type="impl:MynameService">
> <wsdlsoap:binding style="document"
> transport="http://schemas.xmlsoap.org/soap/http" />
>
> <wsdlperation name="getSession">
> <wsdlsoapperation soapAction="" />
> <wsdl:input name="getSessionRequest">
> <wsdlsoap:header message="impl:soapHeader" part="sessionID"
> use="literal"/>
> <wsdlsoap:body namespace="urn:myname.com" use="literal" />
> </wsdl:input>
> <wsdlutput name="getSessionResponse">
> <wsdlsoap:header message="impl:soapHeader" part="sessionID"
> use="literal"/>
> <wsdlsoap:body namespace="urn:myname.com" use="literal" />
> </wsdlutput>
> </wsdlperation>
>
> <wsdlperation name="closeSession">
> <wsdlsoapperation soapAction="" />
> <wsdl:input name="closeSessionRequest">
> <wsdlsoap:header message="impl:soapHeader" part="sessionID"
> use="literal"/>
> <wsdlsoap:body namespace="urn:myname.com" use="literal" />
> </wsdl:input>
> <wsdlutput name="closeSessionResponse">
> <wsdlsoap:header message="impl:soapHeader" part="sessionID"
> use="literal"/>
> <wsdlsoap:body namespace="urn:myname.com" use="literal" />
> </wsdlutput>
> </wsdlperation>
>
> </wsdl:binding>
>
> <wsdl:service name="MynameServiceService">
> <wsdlort binding="impl:MynameServiceSoapBinding"

name="MynameService">
> <wsdlsoap:address
> location="http://localhost:8080/services/MynameService" />
> </wsdlort>
> </wsdl:service>
>
> </wsdl:definitions>
> ====================================
>
> This is the created client proxy:
>
> namespace MyNameSpace{
>
> using System.Diagnostics;
>
> using System.Xml.Serialization;
>
> using System;
>
> using System.Web.Services.Protocols;
>
> using System.ComponentModel;
>
> using System.Web.Services;
>
>
>
> /// <remarks/>
>
> [System.Diagnostics.DebuggerStepThroughAttribute()]
>
> [System.ComponentModel.DesignerCategoryAttribute("c ode")]
>
>

[System.Web.Services.WebServiceBindingAttribute(Nam e="MynameServiceSoapBindi
> ng", Namespace="urn:myname.com")]
>
> public class MynameServiceService :
> System.Web.Services.Protocols.SoapHttpClientProtoc ol {
>
>
> public session sessionID;
>
>
> /// <remarks/>
>
> public MynameServiceService() {
>
> this.Url = "http://localhost:8080/services/MynameService";
>
> }
>
>
> /// <remarks/>
>
> [System.Web.Services.Protocols.SoapHeaderAttribute( "sessionID",
> Direction=System.Web.Services.Protocols.SoapHeader Direction.InOut)]
>
> [System.Web.Services.Protocols.SoapDocumentMethodAt tribute("",
> RequestNamespace="urn:myname.com", ResponseNamespace="urn:myname.com",
> Use=System.Web.Services.Description.SoapBindingUse .Literal,
> ParameterStyle=System.Web.Services.Protocols.SoapP arameterStyle.Wrapped)]
>
> [return: System.Xml.Serialization.XmlElementAttribute("getS essionReturn")]
>
> public string
>

getSession([System.Xml.Serialization.XmlElementdttribute(Form= System.Xml.Sch
> ema.XmlSchemaForm.Unqualified)] string username,
>

[System.Xml.Serialization.XmlElementAttribute(Form= System.Xml.Schema.XmlSche
> maForm.Unqualified)] string password) {
>
> object[] results = this.Invoke("getSession", new object[] {
>
> username,
>
> password});
>
> return ((string)(results[0]));
>
> }
>
>
> /// <remarks/>
>
> public System.IAsyncResult BegingetSession(string username, string

password,
> System.AsyncCallback callback, object asyncState) {
>
> return this.BeginInvoke("getSession", new object[] {
>
> username,
>
> password}, callback, asyncState);
>
> }
>
>
> /// <remarks/>
>
> public string EndgetSession(System.IAsyncResult asyncResult) {
>
> object[] results = this.EndInvoke(asyncResult);
>
> return ((string)(results[0]));
>
> }
>
>
> /// <remarks/>
>
> [System.Web.Services.Protocols.SoapHeaderAttribute( "sessionID",
> Direction=System.Web.Services.Protocols.SoapHeader Direction.InOut)]
>
> [System.Web.Services.Protocols.SoapDocumentMethodAt tribute("",
> RequestNamespace="urn:myname.com", ResponseNamespace="urn:myname.com",
> Use=System.Web.Services.Description.SoapBindingUse .Literal,
> ParameterStyle=System.Web.Services.Protocols.SoapP arameterStyle.Wrapped)]
>
> public void closeSession() {
>
> this.Invoke("closeSession", new object[0]);
>
> }
>
>
> /// <remarks/>
>
> public System.IAsyncResult BegincloseSession(System.AsyncCallback

callback,
> object asyncState) {
>
> return this.BeginInvoke("closeSession", new object[0], callback,
> asyncState);
>
> }
>
>
> /// <remarks/>
>
> public void EndcloseSession(System.IAsyncResult asyncResult) {
>
> this.EndInvoke(asyncResult);
>
> }
>
> }
>
>
> /// <remarks/>
>
> [System.Xml.Serialization.XmlTypeAttribute(Namespac e="urn:myname.com")]
>
> [System.Xml.Serialization.XmlRootAttribute("session ID",
> Namespace="urn:myname.com", IsNullable=false)]
>
> public class session : System.Web.Services.Protocols.SoapHeader {
>
>
> /// <remarks/>
>
>

[System.Xml.Serialization.XmlElementAttribute(Form= System.Xml.Schema.XmlSche
> maForm.Unqualified)]
>
> public long id;
>
> }
>
> }
>
>
>
>
>
>
> "Dino Chiesa [Microsoft]" <(E-Mail Removed)> wrote in message
> news:%(E-Mail Removed)...
> > yes, I think you are correct. the xsi:type="xsd:long" seems to be
> > incorrect.
> >
> > BUT!
> >
> > We are changing the WSDL here without modifying the server. The WSDL
> > documents how we would like the service to appear, but if we design the

> WSDL
> > independently of the implementation of the service (in AXIS) , then

there
> is
> > no way of knowing if the two independent things coincide.
> >
> >
> > It appears that AXIS is using doc/literal for the SOAP body and
> > soap-section-5 encoded for the SOAP header. Can you check this in the
> > server/service implementation?
> >
> > --------------------
> >
> > It seems like you may be using the AXIS SimpleSessionHandler ? If so,
> > there are others who have tried to get this to work and had troubles,

for
> > example see the axis user mailing list archive, eg
> > http://marc.theaimsgroup.com/?l=axis...4009529949&w=2
> >
> > or
> > http://marc.theaimsgroup.com/?l=axis...4463001241&w=2
> >
> > or to search the archive:
> > http://marc.theaimsgroup.com/?l=axis...ionhandler&q=b
> >
> >
> > The problem is that AXIS's WSDL2Java tool does not handle soapheaders as
> > defined in WSDL. If you have a WSDL (such as you have constructed here)
> > that specifies a soapheader to be used in the input message, the output
> > message, or both, then the Java implementation generated from AXIS'
> > "wsdl2java --server-side" does not have any support for that header. As

a
> > developer using AXIS, you need to provide a handler to extract the

> header,
> > or insert the header, as appropriate.
> >
> > The "SimpleSessionHandler" code included with AXIS v1.1 shows this. As

> you
> > can see, there is some DOM walking you have to do to extract the header

> and
> > de-marshal it and validate it and so on. I suppose there is similar

work
> > you have to do to "add" the header to the response.
> >
> > But even with all this I am not sure why the header would be section-5
> > encoded when the body is not. In the WSDL model, the soap body can in
> > fact be a different "use" than the header. In other words the literal or
> > section-5 encoded is specified on the body independently from the

header.
> > Eg,
> >
> > <wsdlutput name="getSessionResponse">
> > <wsdlsoap:header message="impl:soapHeader" part="sessionID"
> > use="literal"/>
> > <wsdlsoap:body namespace="urn:myname.com" use="literal" />
> > </wsdlutput>
> >
> >
> >
> > -Dino
> >
> >
> >
> > "Zihong Lu" <(E-Mail Removed)> wrote in message
> > news:(E-Mail Removed)...
> > > Dino,
> > >
> > > I have changed the session declaration in WSDL to what you suggested,

> as
> > > showing here:
> > >
> > > <schema targetNamespace="http://xml.apache.org/axis/session"
> > > xmlns="http://www.w3.org/2001/XMLSchema">
> > > <element name="sessionID" type="sens:session"/>
> > > <complexType name="session">
> > > <sequence>
> > > <element minOccurs="1" maxOccurs="1" name="id"

> > type="xsd:long"/>
> > > </sequence>
> > > </complexType>
> > > </schema>
> > >
> > > where namespace "sens" was defined in the <wsdl:definitions> as
> > > xmlns:sens="http://xml.apache.org/axis/session".
> > >
> > > Yes, the generated proxy code now has the same session class derived

> from
> > > SoapHeader, as earlier. However, compared to the code generated from
> > > simpleType declaration in WSDL earlier , the class memeber "id" now

has
> a
> > > data type of long, instead of the earlier string[], and it has a

> sensible
> > > name "id" that I set, instead of the earlier generated name of "Text"

> > (these
> > > are the only changes in the whole generated client proxy file):
> > >
> > > /// <remarks/>
> > >

> >

>

[System.Xml.Serialization.XmlTypeAttribute(Namespac e="http://xml.apache.org/
> > > axis/session")]
> > > [System.Xml.Serialization.XmlRootAttribute("session ID",
> > > Namespace="http://xml.apache.org/axis/session", IsNullable=false)]
> > > public class session : System.Web.Services.Protocols.SoapHeader {
> > >
> > > /// <remarks/>
> > >
> > >

> >

>

[System.Xml.Serialization.XmlElementAttribute(Form= System.Xml.Schema.XmlSche
> > > maForm.Unqualified)]
> > > public long id;
> > > }
> > >
> > > I have noticed that the "id" is unqulified, while in the example you

> > showed
> > > the "s" does not have the "Unqualified" attribute.
> > >
> > > However, even with this change, I still got the same error of
> > > InvalidOperationException. Since the wsdl file is manually edited, I

> did
> > > not change Axis server side. For the session handling, I simply use
> > > SimpleSessionHandler handler, a convenient handler that Axis provided.
> > >
> > > I have also tested the code with the "Form = ... Unqualified"

manually
> > > removed from the generated proxy code, I still got the same error.

The
> > eror
> > > message is copied here again for completeness:
> > > =======================================
> > > Unhandled Exception: System.InvalidOperationException: There is an

error
> > in
> > > XML
> > > document (4, 4). ---> System.InvalidOperationException: The specified

> type
> > > was n
> > > ot recognized: name='long',

> namespace='http://www.w3.org/2001/XMLSchema',
> > at
> > > <se
> > > ssionID xmlns='http://xml.apache.org/axis/session'>.
> > > at
> > >

> Microsoft.Xml.Serialization.GeneratedAssembly.XmlS erializationReader1.Read
> > > 1_session(Boolean isNullable, Boolean checkType)
> > > at
> > >

> Microsoft.Xml.Serialization.GeneratedAssembly.XmlS erializationReader1.Read
> > > 8_OutHeaders()
> > > =======================================
> > >
> > > The returned SOAP message is
> > > <?xml version="1.0" encoding="UTF-8"?>
> > > <soapenv:Envelope

> > xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
> > > xmlnssd="http://www.w3.org/2001/XMLSchema"
> > > xmlnssi="http://www.w3.org/2001/XMLSchema-instance">
> > > <soapenv:Header>
> > > <ns1:sessionID soapenv:mustUnderstand="0" xsi:type="xsd:long"
> > >

> >

>

xmlns:ns1="http://xml.apache.org/axis/session">-5227012230670020468</ns1:ses
> > > sionID>
> > > </soapenv:Header>
> > > ...
> > >
> > > the position (4,4) indicated in the error message is the ns1:sessionID

> > tag.
> > > Does this message looks right to you, compared to what WSDL declared?
> > > Somehow I felt the xsi:type="xsd:long" is not right, since dot/lit

style
> > > don't usually have this.
> > >
> > > -Zihong
> > >
> > >
> > >
> > > "Dino Chiesa [Microsoft]" <(E-Mail Removed)> wrote in

message
> > > news:%(E-Mail Removed)...
> > > > If I modify your WSDL to type the session ID this way:
> > > >
> > > > <element name="sessionID" type="sess:session"/>
> > > >
> > > > <complexType name="session">
> > > > <sequence>
> > > > <element minOccurs="1" maxOccurs="1" name="s"
> > > type="xsd:long"/>
> > > > </sequence>
> > > > </complexType>
> > > >
> > > >
> > > > it works, and generates a header class like so:
> > > >
> > > > public class session : System.Web.Services.Protocols.SoapHeader {
> > > > /// <remarks/>
> > > > [System.Xml.Serialization.XmlElementAttribute()]
> > > > public long s;
> > > > }
> > > >
> > > >
> > > > I think the problem is, in .NET the soapheader must derive from
> > > > System.Web.Services.Protocols.SoapHeader . In other words it is a
> > > > complexType. In your WSDL you have it as a simpleType. Generating

a
> > > client
> > > > proxy from that WSDL results in some confusion. Feels like a bug in

> the
> > > > wsdl.exe compiler.
> > > >
> > > > The simple fix is to change the definition of the header type in XSD

> to
> > > the
> > > > above. This generates what you would expect, I think.
> > > >
> > > > But you have to ensure this synchronizes with the AXIS server. If

you
> > are
> > > > generating the server from the WSDL then it should be no problem .
> > > >
> > > > -Dino
> > > >
> > > >
> > > >
> > > >
> > > > "Zihong Lu" <(E-Mail Removed)> wrote in message
> > > > news:%(E-Mail Removed)...
> > > > > Dino,
> > > > >
> > > > > Thanks. That works.
> > > > >
> > > > > Now I have a second issue: the soap header. As you can see from

my
> > > > eariler
> > > > > wsdl file, if I do the following:
> > > > > (1) changed the line to <element name="getSessionReturn"
> > > > type="xsd:string"
> > > > > form="qualified"/>, to solve the null result problem;
> > > > > (2) uncommented out the line to indicate the soap header in the

> return
> > > > > message:
> > > > > <wsdlsoap:header message="impl:soapHeader" part="sessionID"
> > > use="literal"
> > > > > />
> > > > >
> > > > > When invoke the getSession() call, the .net client complained:
> > > > >
> > > > > =========================================
> > > > > System.InvalidOperationException: The specified type was not

> > recognized:
> > > > > name='long',
> > > > > namespace='http://www.w3.org/2001/XMLSchema', at <sessionID
> > > > > xmlns='http://xml.apache.org/axis/session'>.
> > > > >
> > > > > at
> > > > >
> > > >
> > >

> >

>

Microsoft.Xml.Serialization.GeneratedAssembly.XmlS erializationReader1.Read1_
> > > > > session(Boolean isNullable, Boolean checkType)
> > > > > at
> > > > >
> > > >
> > >

> >

>

Microsoft.Xml.Serialization.GeneratedAssembly.XmlS erializationReader1.Read8_
> > > > > OutHeaders()
> > > > >
> > > > > Do I need to create serializer/deserializer for the SOAP header?

I
> > > > thought
> > > > > the created proxy code already recognize it and can serialize it
> > > > > automatically, like gSoap does.
> > > > >
> > > > > Here is the new generated client proxy:
> > > > > ============================
> > > > > namespace MyNameSpace{
> > > > > using System.Diagnostics;
> > > > > using System.Xml.Serialization;
> > > > > using System;
> > > > > using System.Web.Services.Protocols;
> > > > > using System.ComponentModel;
> > > > > using System.Web.Services;
> > > > >
> > > > >
> > > > > /// <remarks/>
> > > > > [System.Diagnostics.DebuggerStepThroughAttribute()]
> > > > > [System.ComponentModel.DesignerCategoryAttribute("c ode")]
> > > > >
> > > > >
> > > >
> > >

> >

>

[System.Web.Services.WebServiceBindingAttribute(Nam e="MynameServiceSoapBindi
> > > > > ng", Namespace="urn:myname.com")]
> > > > > public class MynameServiceService :
> > > > > System.Web.Services.Protocols.SoapHttpClientProtoc ol {
> > > > >
> > > > > public session sessionID;
> > > > >
> > > > > /// <remarks/>
> > > > > public MynameServiceService() {
> > > > > this.Url =

> "http://localhost:8080/services/MynameService";
> > > > > }
> > > > >
> > > > > /// <remarks/>
> > > > >

> > [System.Web.Services.Protocols.SoapHeaderAttribute( "sessionID",
> > > > >

Direction=System.Web.Services.Protocols.SoapHeader Direction.InOut)]
> > > > >

> [System.Web.Services.Protocols.SoapDocumentMethodAt tribute("",
> > > > > RequestNamespace="urn:myname.com",

> ResponseNamespace="urn:myname.com",
> > > > > Use=System.Web.Services.Description.SoapBindingUse .Literal,
> > > > >
> > >

> ParameterStyle=System.Web.Services.Protocols.SoapP arameterStyle.Wrapped)]
> > > > > [return:
> > > > > System.Xml.Serialization.XmlElementAttribute("getS essionReturn")]
> > > > > public string
> > > > >
> > > >
> > >

> >

>

getSession([System.Xml.Serialization.XmlElementAttribute(Form= System.Xml.Sch
> > > > > ema.XmlSchemaForm.Unqualified)] string username,
> > > > >
> > > >
> > >

> >

>

[System.Xml.Serialization.XmlElementAttribute(Form= System.Xml.Schema.XmlSche
> > > > > maForm.Unqualified)] string password) {
> > > > > object[] results = this.Invoke("getSession", new

> object[]
> > {
> > > > > username,
> > > > > password});
> > > > > return ((string)(results[0]));
> > > > > }
> > > > >
> > > > > /// <remarks/>
> > > > > public System.IAsyncResult BegingetSession(string

username,
> > > string
> > > > > password, System.AsyncCallback callback, object asyncState) {
> > > > > return this.BeginInvoke("getSession", new object[] {
> > > > > username,
> > > > > password}, callback, asyncState);
> > > > > }
> > > > >
> > > > > /// <remarks/>
> > > > > public string EndgetSession(System.IAsyncResult

asyncResult)
> {
> > > > > object[] results = this.EndInvoke(asyncResult);
> > > > > return ((string)(results[0]));
> > > > > }
> > > > >
> > > > > /// <remarks/>
> > > > >

> > [System.Web.Services.Protocols.SoapHeaderAttribute( "sessionID",
> > > > >

Direction=System.Web.Services.Protocols.SoapHeader Direction.InOut)]
> > > > >

> [System.Web.Services.Protocols.SoapDocumentMethodAt tribute("",
> > > > > RequestNamespace="urn:myname.com",

> ResponseNamespace="urn:myname.com",
> > > > > Use=System.Web.Services.Description.SoapBindingUse .Literal,
> > > > >
> > >

> ParameterStyle=System.Web.Services.Protocols.SoapP arameterStyle.Wrapped)]
> > > > > public void closeSession() {
> > > > > this.Invoke("closeSession", new object[0]);
> > > > > }
> > > > >
> > > > > /// <remarks/>
> > > > > public System.IAsyncResult
> > > BegincloseSession(System.AsyncCallback
> > > > > callback, object asyncState) {
> > > > > return this.BeginInvoke("closeSession", new object[0],
> > > > callback,
> > > > > asyncState);
> > > > > }
> > > > >
> > > > > /// <remarks/>
> > > > > public void EndcloseSession(System.IAsyncResult

asyncResult)
> {
> > > > > this.EndInvoke(asyncResult);
> > > > > }
> > > > > }
> > > > >
> > > > > /// <remarks/>
> > > > >
> > > > >
> > > >
> > >

> >

>

[System.Xml.Serialization.XmlTypeAttribute(Namespac e="http://xml.apache.org/
> > > > > axis/session")]
> > > > > [System.Xml.Serialization.XmlRootAttribute("session ID",
> > > > > Namespace="http://xml.apache.org/axis/session", IsNullable=false)]
> > > > > public class session :

System.Web.Services.Protocols.SoapHeader
> {
> > > > >
> > > > > /// <remarks/>
> > > > > [System.Xml.Serialization.XmlTextAttribute()]
> > > > > public string[] Text;
> > > > > }
> > > > > }
> > > > >
> > > > >
> > > > >
> > > > >
> > > > >
> > > > >
> > > > >
> > >
> > >

> >
> >

>
>



 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Axis 1.4: document/literal wrapped style is missing operation name Jan Java 12 09-01-2008 06:37 AM
1. Ruby result: 101 seconds , 2. Java result:9.8 seconds, 3. Perl result:62 seconds Michael Tan Ruby 32 07-21-2005 03:23 PM
null object returnd to .net client while calling axis web service chandra kantha via .NET 247 ASP .Net Web Services 0 03-29-2005 02:32 PM
AXIS jars org.apache.axis.wsi.* and org.apache.axis.transport.jms.* unkwb@web.de Java 0 02-23-2005 04:02 PM
axis.jar does not contain org.apache.axis.client.ServiceClient? Joey Vendetta Java 0 04-01-2004 05:51 PM



Advertisments