You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-user@axis.apache.org by Zihong Lu <zl...@extremenetworks.com> on 2004/06/23 00:32:08 UTC

problem using soap header for session ID for .net clients

I have run into a problem using sessionID in soap header, for .net clients
that uses wsdl.exe generated proxy.  I have followed this link to use
SimpleSessionHandler, 

http://www.fawcette.com/javapro/2003_04/online/wsdl_kjones_04_29_03/

with which I have successfully made it work for axis, gSoap, and SOAP::Lite
perl clients.  

I have also used the method described in this link
http://marc.theaimsgroup.com/?l=axis-user&m=108324718302792&w=2, to try
connect .net clients without any success.  I was using doc/lit wrapped
style.  While the link there did mention it is for doc/literal style, and
the wsdl indicates that it is doc/literal style,  (see wsdl included at the
end), the response soap header looks to me is not doc/lit style. Any idea
why .net doesn't work?

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

the axis-> .net response:
=========================
287
<?xml version="1.0" encoding="UTF-8"?>
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:xsi="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>
...


.net client comlained about 

Unhandled Exception: System.InvalidOperationException: There is an error in
XML document (4, 4). ---> 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.XmlSerializationReader1.Read1_
session(Boolean isNullable, Boolean checkType)
at
Microsoft.Xml.Serialization.GeneratedAssembly.XmlSerializationReader1.Read8_
OutHeaders()
...


Here is the wsdl file
============================
<?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/"
    xmlns:xsd="http://www.w3.org/2001/XMLSchema"
    xmlns:sens="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="sens: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" 
                   form="qualified"/>
          </sequence>
        </complexType>
    </element>

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

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

    </schema>
</wsdl:types>

<wsdl:message name="soapHeader">
    <wsdl:part name="sessionID" element="sens:sessionID" />
</wsdl:message>

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

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

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

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

<wsdl:portType name="MynameService">

    <wsdl:operation name="getSession" parameterOrder="">
        <wsdl:input message="impl:getSessionRequest"
name="getSessionRequest" />
        <wsdl:output message="impl:getSessionResponse"
name="getSessionResponse" />
    </wsdl:operation>

    <wsdl:operation name="closeSession">
        <wsdl:input message="impl:closeSessionRequest"
name="closeSessionRequest" />
        <wsdl:output message="impl:closeSessionResponse"
name="closeSessionResponse" />
    </wsdl:operation>

</wsdl:portType>

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

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

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

</wsdl:binding>

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

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