axis-java-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Daniel Ivanov <daniel.iva...@aus.teleca.se>
Subject Null values in a webservice method call
Date Tue, 16 Sep 2003 08:41:00 GMT
I have searched for this topic in all the Axis mailing lists in vain.
What it seems strange to me is that nobody har risen this issue previously.
So may be I am missisng something out...

I have the following problem.
I have deployed a webservice via Axis 1.1 and my client runs in .NET
environment.
I also use TCPMON to monitor the traffic between my server and the client.
My webservice exposes several methods that takes a number of parameters.
The problem arises when some of the parameters in a method call have null
values.
Via TCPMON I can see that parameters with null values are omitted in the
outgoing SOAP request.
What happens then is that Axis loses the real order of the method parameters
and tries to cast them according to order specified the wsdl file.
In best case there woulbe be an answer like that:
<soapenv:Fault>   
            <faultcode>soapenv:Server.userException</faultcode>   
            <faultstring>org.xml.sax.SAXException: Bad types (class
[Ljava.lang.Object; -&gt; class java.lang.String)</faultstring>   
            <detail/>  
         </soapenv:Fault> 

In the worst case the cast might succeed and and your request would be
processed but the response would not be what you expected...

However, if I manually manipulate the SOAP request by adding 
<parameterX xsi:nil="true"></parameterX>
and I preserve the order of the method parameters then everything works
fine, i.e. Axis recives a null paramater and processes it as it should.
Axis just looks at the order of the parameters, not at their names.

The Soap 1.1 specification says:
"A NULL value or a default value MAY be represented by omission of the
accessor element. A NULL value MAY also be indicated by an accessor element
containing the attribute xsi:null with value '1' or possibly other
application-dependent attributes and values." 
Is this the cause of the problem - the .Net and Axis have chosen different
implementations of the SOAP standard?
Is there a way to specify in the wsdl file that the parameters that some of
the prameters might be null.
What is the best way to send null values?

Regards 
/ Daniel


Here come some relevant attachements:


 <<SoapPKCS7.wsdl>> 

<?xml version="1.0" encoding="utf-8"?>
<definitions xmlns:s1="http://127.0.0.1:8080/services/SoapPKCS7"
xmlns:http="http://schemas.xmlsoap.org/wsdl/http/"
xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
xmlns:s="http://www.w3.org/2001/XMLSchema" xmlns:s0="urn:StringPair"
xmlns:s3="http://common.webservices.layer6.tss.aus.teleca.com"
xmlns:s2="urn:PropertyObject" xmlns:s4="urn:SoapPKCS7ResultSet"
xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/"
xmlns:tm="http://microsoft.com/wsdl/mime/textMatching/"
xmlns:mime="http://schemas.xmlsoap.org/wsdl/mime/"
targetNamespace="http://127.0.0.1:8080/services/SoapPKCS7"
xmlns="http://schemas.xmlsoap.org/wsdl/">
  <types>
    <s:schema targetNamespace="urn:StringPair">
      <s:import namespace="http://schemas.xmlsoap.org/soap/encoding/" />
      <s:complexType name="StringPair">
        <s:sequence>
          <s:element name="leftString" nillable="true" type="s:string" />
          <s:element name="rightString" nillable="true" type="s:string" />
        </s:sequence>
      </s:complexType>
    </s:schema>
    <s:schema targetNamespace="http://127.0.0.1:8080/services/SoapPKCS7">
      <s:import namespace="http://schemas.xmlsoap.org/soap/encoding/" />
      <s:complexType name="ArrayOf_tns2_StringPair">
        <s:complexContent mixed="false">
          <s:restriction base="soapenc:Array">
            <s:attribute d7p1:arrayType="s0:StringPair[]"
ref="soapenc:arrayType" xmlns:d7p1="http://schemas.xmlsoap.org/wsdl/" />
          </s:restriction>
        </s:complexContent>
      </s:complexType>
      <s:complexType name="ArrayOf_xsd_dateTime">
        <s:complexContent mixed="false">
          <s:restriction base="soapenc:Array">
            <s:attribute d7p1:arrayType="s:dateTime[]"
ref="soapenc:arrayType" xmlns:d7p1="http://schemas.xmlsoap.org/wsdl/" />
          </s:restriction>
        </s:complexContent>
      </s:complexType>
      <s:complexType name="ArrayOf_xsd_string">
        <s:complexContent mixed="false">
          <s:restriction base="soapenc:Array">
            <s:attribute d7p1:arrayType="s:string[]" ref="soapenc:arrayType"
xmlns:d7p1="http://schemas.xmlsoap.org/wsdl/" />
          </s:restriction>
        </s:complexContent>
      </s:complexType>
    </s:schema>
    <s:schema targetNamespace="urn:PropertyObject">
      <s:import namespace="http://schemas.xmlsoap.org/soap/encoding/" />
      <s:complexType name="PropertyObject">
        <s:sequence>
          <s:element name="stringPairs" nillable="true"
type="s1:ArrayOf_tns2_StringPair" />
          <s:element name="valueDateArray" nillable="true"
type="s1:ArrayOf_xsd_dateTime" />
          <s:element name="valueStringArray" nillable="true"
type="s1:ArrayOf_xsd_string" />
          <s:element name="valueDate" nillable="true" type="s:dateTime" />
        </s:sequence>
      </s:complexType>
    </s:schema>
    <s:schema
targetNamespace="http://common.webservices.layer6.tss.aus.teleca.com">
      <s:import namespace="http://schemas.xmlsoap.org/soap/encoding/" />
      <s:complexType name="SoapResultObject">
        <s:sequence>
          <s:element name="extractedProperties" nillable="true"
type="s2:PropertyObject" />
          <s:element name="resultCode" type="s:int" />
          <s:element name="resultMessage" nillable="true" type="s:string" />
          <s:element name="transactionId" nillable="true" type="s:string" />
        </s:sequence>
      </s:complexType>
    </s:schema>
    <s:schema targetNamespace="urn:SoapPKCS7ResultSet">
      <s:import namespace="http://schemas.xmlsoap.org/soap/encoding/" />
      <s:complexType name="SoapPKCS7ResultSet">
        <s:complexContent mixed="false">
          <s:extension base="s3:SoapResultObject">
            <s:sequence>
              <s:element name="contentData" type="s:base64Binary" />
              <s:element name="pkcs7SignedData" type="s:base64Binary" />
            </s:sequence>
          </s:extension>
        </s:complexContent>
      </s:complexType>
    </s:schema>
  </types>
  <message name="verifyPKCS7SignedDataRequest">
    <part name="signedDataBase64" type="s:string" />
    <part name="propertiesToExtract" type="s1:ArrayOf_xsd_string" />
    <part name="serviceAlias" type="s:string" />
    <part name="customPolicy" type="s1:ArrayOf_tns2_StringPair" />
    <part name="transactionId" type="s:string" />
  </message>
  <message name="extractPKCS7PropertiesRequest">
    <part name="signedDataBase64" type="s:string" />
    <part name="propertiesToExtract" type="s1:ArrayOf_xsd_string" />
    <part name="transactionId" type="s:string" />
  </message>
  <message name="verifyPKCS7SignedDataResponse">
    <part name="verifyPKCS7SignedDataReturn" type="s4:SoapPKCS7ResultSet" />
  </message>
  <message name="createPKCS7SignedDataRequest">
    <part name="contentDataBase64" type="s:string" />
    <part name="keyPairAlias" type="s:string" />
    <part name="timestamp" type="s:string" />
    <part name="serviceAlias" type="s:string" />
    <part name="customPolicy" type="s1:ArrayOf_tns2_StringPair" />
    <part name="transactionId" type="s:string" />
  </message>
  <message name="extractPKCS7PropertiesResponse">
    <part name="extractPKCS7PropertiesReturn" type="s4:SoapPKCS7ResultSet"
/>
  </message>
  <message name="createPKCS7SignedDataResponse">
    <part name="createPKCS7SignedDataReturn" type="s4:SoapPKCS7ResultSet" />
  </message>
  <portType name="SoapPKCS7">
    <operation name="verifyPKCS7SignedData" parameterOrder="signedDataBase64
propertiesToExtract serviceAlias customPolicy transactionId">
      <input name="verifyPKCS7SignedDataRequest"
message="s1:verifyPKCS7SignedDataRequest" />
      <output name="verifyPKCS7SignedDataResponse"
message="s1:verifyPKCS7SignedDataResponse" />
    </operation>
    <operation name="extractPKCS7Properties"
parameterOrder="signedDataBase64 propertiesToExtract transactionId">
      <input name="extractPKCS7PropertiesRequest"
message="s1:extractPKCS7PropertiesRequest" />
      <output name="extractPKCS7PropertiesResponse"
message="s1:extractPKCS7PropertiesResponse" />
    </operation>
    <operation name="createPKCS7SignedData"
parameterOrder="contentDataBase64 keyPairAlias timestamp serviceAlias
customPolicy transactionId">
      <input name="createPKCS7SignedDataRequest"
message="s1:createPKCS7SignedDataRequest" />
      <output name="createPKCS7SignedDataResponse"
message="s1:createPKCS7SignedDataResponse" />
    </operation>
  </portType>
  <binding name="SoapPKCS7SoapBinding" type="s1:SoapPKCS7">
    <soap:binding transport="http://schemas.xmlsoap.org/soap/http"
style="rpc" />
    <operation name="verifyPKCS7SignedData">
      <soap:operation soapAction="" />
      <input name="verifyPKCS7SignedDataRequest">
        <soap:body use="encoded"
namespace="http://soappkcs7.webservices.layer6.tss.aus.teleca.com"
encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" />
      </input>
      <output name="verifyPKCS7SignedDataResponse">
        <soap:body use="encoded"
namespace="http://127.0.0.1:8080/services/SoapPKCS7"
encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" />
      </output>
    </operation>
    <operation name="extractPKCS7Properties">
      <soap:operation soapAction="" />
      <input name="extractPKCS7PropertiesRequest">
        <soap:body use="encoded"
namespace="http://soappkcs7.webservices.layer6.tss.aus.teleca.com"
encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" />
      </input>
      <output name="extractPKCS7PropertiesResponse">
        <soap:body use="encoded"
namespace="http://127.0.0.1:8080/services/SoapPKCS7"
encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" />
      </output>
    </operation>
    <operation name="createPKCS7SignedData">
      <soap:operation soapAction="" />
      <input name="createPKCS7SignedDataRequest">
        <soap:body use="encoded"
namespace="http://soappkcs7.webservices.layer6.tss.aus.teleca.com"
encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" />
      </input>
      <output name="createPKCS7SignedDataResponse">
        <soap:body use="encoded"
namespace="http://127.0.0.1:8080/services/SoapPKCS7"
encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" />
      </output>
    </operation>
  </binding>
  <service name="SoapPKCS7Service">
    <port name="SoapPKCS7" binding="s1:SoapPKCS7SoapBinding">
      <soap:address location="http://127.0.0.1:8080/services/SoapPKCS7" />
    </port>
  </service>
</definitions>



____________________________________________________________________________
__________________________________________________

A SOAP request where the called method is createPKCS7SignedData and the
parameter timestamp=null.
As you acan see the timnestamp is not included in the SOAP request.

   <soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/"
xmlns:tns="http://127.0.0.1:8080/services/SoapPKCS7"
xmlns:types="http://127.0.0.1:8080/services/SoapPKCS7/encodedTypes"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:xsd="http://www.w3.org/2001/XMLSchema">
      <soap:Body
soap:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
         <q1:createPKCS7SignedData
xmlns:q1="http://soappkcs7.webservices.layer6.tss.aus.teleca.com">
            <contentDataBase64
xsi:type="xsd:string">AQMEBTYELS0tLTYtNjYt</contentDataBase64>
            <keyPairAlias xsi:type="xsd:string">test_0</keyPairAlias>
<timestamp xsi:nil="true"></timestamp>
            <serviceAlias xsi:type="xsd:string">std_service</serviceAlias>
            <customPolicy href="#id1" />
            <transactionId xsi:type="xsd:string">test case</transactionId>
         </q1:createPKCS7SignedData>
         <soapenc:Array id="id1" xmlns:q2="urn:StringPair"
soapenc:arrayType="q2:StringPair[3]">
            <Item href="#id2" />
            <Item href="#id3" />
            <Item href="#id4" />
         </soapenc:Array>
         <q3:StringPair id="id2" xsi:type="q3:StringPair"
xmlns:q3="urn:StringPair">
            <leftString
xsi:type="xsd:string">service.signature.creation.hashAlg</leftString>
            <rightString xsi:type="xsd:string">sha1</rightString>
         </q3:StringPair>
         <q4:StringPair id="id3" xsi:type="q4:StringPair"
xmlns:q4="urn:StringPair">
            <leftString
xsi:type="xsd:string">service.certificatechain.requireTimeValidation</leftSt
ring>
            <rightString xsi:type="xsd:string">true</rightString>
         </q4:StringPair>
         <q5:StringPair id="id4" xsi:type="q5:StringPair"
xmlns:q5="urn:StringPair">
            <leftString
xsi:type="xsd:string">service.signature.creation.includeTimeStamp</leftStrin
g>
            <rightString xsi:type="xsd:string">none</rightString>
         </q5:StringPair>
      </soap:Body>
   </soap:Envelope>

----------------------------------------------------------------------------
----------------------------------------------------------------------------
---------------------------------------------------------------------
Here comes the response- Axis expects a String element, but but receives a
Object of another types since the parameter "timestamp" was not included in
the request:

HTTP/1.1 100 Continue  HTTP/1.1 500 Internal Server Error Content-Type:
text/xml; charset=utf-8 Date: Tue, 16 Sep 2003 07:01:08 GMT
Transfer-Encoding: chunked Server: Apache Tomcat/4.0.3 (HTTP/1.1 Connector)
1ef <?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:Body>  
         <soapenv:Fault>   
            <faultcode>soapenv:Server.userException</faultcode>   
            <faultstring>org.xml.sax.SAXException: Bad types (class
[Ljava.lang.Object; -&gt; class java.lang.String)</faultstring>   
            <detail/>  
         </soapenv:Fault> 
      </soapenv:Body>
   </soapenv:Envelope>


____________________________________________________________________________
__________________________________________________

A SOAP request where the called method is createPKCS7SignedData. Here I have
manipulated the SOAP reguest by incling the following line:
 <timestamp xsi:nil="true"></timestamp>            

<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/"
xmlns:tns="http://127.0.0.1:8080/services/SoapPKCS7"
xmlns:types="http://127.0.0.1:8080/services/SoapPKCS7/encodedTypes"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:xsd="http://www.w3.org/2001/XMLSchema">      
      <soap:Body
soap:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">         
         <q1:createPKCS7SignedData
xmlns:q1="http://soappkcs7.webservices.layer6.tss.aus.teleca.com">

            <contentDataBase64
xsi:type="xsd:string">AQMEBTYELS0tLTYtNjYt</contentDataBase64>            
            <keyPairAlias xsi:type="xsd:string">test_0</keyPairAlias>
            <timestamp xsi:nil="true"></timestamp>            
            <serviceAlias xsi:type="xsd:string">std_service</serviceAlias>

            <customPolicy href="#id1" />            
            <transactionId xsi:type="xsd:string">test case</transactionId>

         </q1:createPKCS7SignedData>         
         <soapenc:Array id="id1" xmlns:q2="urn:StringPair"
soapenc:arrayType="q2:StringPair[3]">            
            <Item href="#id2" />            
            <Item href="#id3" />            
            <Item href="#id4" />         
         </soapenc:Array>         
         <q3:StringPair id="id2" xsi:type="q3:StringPair"
xmlns:q3="urn:StringPair">            
            <leftString
xsi:type="xsd:string">service.signature.creation.hashAlg</leftString>

            <rightString xsi:type="xsd:string">sha1</rightString>         
         </q3:StringPair>         
         <q4:StringPair id="id3" xsi:type="q4:StringPair"
xmlns:q4="urn:StringPair">            
            <leftString
xsi:type="xsd:string">service.certificatechain.requireTimeValidation</leftSt
ring>            
            <rightString xsi:type="xsd:string">true</rightString>         
         </q4:StringPair>         
         <q5:StringPair id="id4" xsi:type="q5:StringPair"
xmlns:q5="urn:StringPair">            
            <leftString
xsi:type="xsd:string">service.signature.creation.includeTimeStamp</leftStrin
g>            
            <rightString xsi:type="xsd:string">none</rightString>         
         </q5:StringPair>      
      </soap:Body>   
   </soap:Envelope>


----------------------------------------------------------------------------
----------------------------------------------------------------------------
---------------------------------------------------------------------
This is the response - everything is fine.


HTTP/1.1 100 Continue  HTTP/1.1 200 OK Content-Type: text/xml; charset=utf-8
Date: Tue, 16 Sep 2003 07:02:49 GMT Transfer-Encoding: chunked Server:
Apache Tomcat/4.0.3 (HTTP/1.1 Connector)  a8b <?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:Body>  
         <ns1:createPKCS7SignedDataResponse
soapenv:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"
xmlns:ns1="http://soappkcs7.webservices.layer6.tss.aus.teleca.com">   
            <ns1:createPKCS7SignedDataReturn href="#id0"/>  
         </ns1:createPKCS7SignedDataResponse>  
         <multiRef id="id0" soapenc:root="0"
soapenv:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"
xsi:type="ns2:SoapPKCS7ResultSet"
xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/"
xmlns:ns2="urn:SoapPKCS7ResultSet">   
            <contentData xsi:type="xsd:base64Binary" xsi:nil="true"/>   
            <extractedProperties xsi:type="ns3:PropertyObject"
xsi:nil="true" xmlns:ns3="urn:PropertyObject"/>   
            <resultCode xsi:type="xsd:int">0</resultCode>   
            <pkcs7SignedData
xsi:type="xsd:base64Binary">MIIEVwYJKoZIhvcNAQcCoIIES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VtIEFCMQwwCgYDVQQLEwNFSUExGTAXBgNVBAMTEFRT
UyBUZXN0IFJvb3QgQ0ExHDAaBgkqhkiG9w0BCQEWDWZybGFAYXVzeXMuc2UxCjAIBgNVBAUTATAC
AQEwCQYFKw4DAhoFAKA/MBgGCSqGSIb3DQEJAzELBgkqhkiG9w0BBwEwIwYJKoZIhvcNAQkEMRYE
FECpECua+3eEVZ+vp8bCgz5xeZXVMA0GCSqGSIb3DQEBAQUABIGAMtJItezjov9xH9wBEhIeOiOn
l6YG8ITa5acuJQJomnyZEMIu7PyfTPBlAlHK3IWEg4lgQJQwyP0mC8kaxSWP+V6vxxgCMIfhfFv9
Io7GHvV2hJXXOhnReg29XwaX0xrmLkKegHovcS0oPRaMqpHR+6AmTeYoaY1YBPVpHgzrepk=</pk
cs7SignedData>   
            <resultMessage xsi:type="xsd:string">No errors
occurred.</resultMessage>   
            <transactionId xsi:type="xsd:string">client:127.0.0.1/test
case</transactionId>  
         </multiRef> 
      </soapenv:Body>
   </soapenv:Envelope>





Mime
View raw message