user1631072
user1631072

Reputation: 61

How to pass null value to Document Literal SOAP Request

Hi, I am passing the null value for the resourcekey in the SOAP Request as below.

 <urn:createNetwork>
 <net:resourceIdentityInfo>
        <api:resourceKey ></api:resourceKey>
           <api:resourceName>TEST2</api:resourceName>
           <api:resourceType>NETWORK</api:resourceType>
 </net:resourceIdentityInfo>
 </urn:createNetwork>

The sample WSDL file for this request is as below:

 <wsdl:operation name="createNetwork">

     <wsdlsoap:operation soapAction=""/>

     <wsdl:input name="createNetworkRequest">

        <wsdlsoap:body use="literal"/>

     </wsdl:input>

     <wsdl:output name="createNetworkResponse">

        <wsdlsoap:body use="literal"/>

     </wsdl:output>

      </wsdl:operation>

  <element name="createNetwork">
 <complexType>
 <sequence>
  <element name="in0" type="tns5:NetworkInfo"/>
 </sequence>
</complexType>
 </element>
 <element name="createNetworkResponse">
 <complexType>
 <sequence>
  <element name="createNetworkReturn" type="tns2:ResourceIdentityInfo"/>
 </sequence>
</complexType>
</element>
<wsdl:message name="createNetworkRequest">
  <wsdl:part element="intf:createNetwork" name="parameters">
  </wsdl:part>
</wsdl:message>
 <complexType name="NetworkInfo">
<sequence>
 <element name="comments" nillable="true" type="impl:ArrayOf_xsd_anyType"/>
 <element name="description" nillable="true" type="xsd:string"/>
 <element name="dnsDomainName" nillable="true" type="xsd:string"/>
 <element name="documentUrls" nillable="true" type="impl:ArrayOf_xsd_anyType"/>
 <element name="resourceIdentityInfo" nillable="true" type="tns2:ResourceIdentityInfo"/>
</sequence>
</complexType>
<complexType name="ResourceIdentityInfo">
<sequence>
 <element name="resourceKey"  nillable="true" type="xsd:string"/>
 <element name="resourceName" nillable="true" type="xsd:string"/>
 <element name="resourceType" nillable="true" type="xsd:string"/>
</sequence>
</complexType>

I have declared as nillable=true in all the places. If i pass the resourcekey as empty, in SOAP UI I am getting null pointer exception.

<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>java.lang.NullPointerException</faultstring>
     <detail>
        <ns1:hostname   xmlns:ns1="http://xml.apache.org/axis/">linbgg244.lss.emc.com</ns1:hostname>
     </detail>
  </soapenv:Fault>
</soapenv:Body>
</soapenv:Envelope>

I have tried with

<api:resourceKey xsi:nil="true" ></api:resourceKey> 

The same null pointer exception is getting.

Could you please guide to resolve the issue?

Thanks in advance.

Upvotes: 0

Views: 5030

Answers (1)

Keerthivasan
Keerthivasan

Reputation: 12880

I don't think you have to pass null here. AFAIK, the webservice code is throwing the NullPointerException during processing of the SOAP request. Try to identify why is that ? and do a null check or make changes in the logic to prevent it.

Upvotes: 1

Related Questions