您好, 我在SOAP请求中传递resourcekey的null值,如下所示。
<urn:createNetwork>
<net:resourceIdentityInfo>
<api:resourceKey ></api:resourceKey>
<api:resourceName>TEST2</api:resourceName>
<api:resourceType>NETWORK</api:resourceType>
</net:resourceIdentityInfo>
</urn:createNetwork>
此请求的示例WSDL文件如下:
<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>
我已在所有地方声明为nillable = true。 如果我将resourcekey作为空传递,在SOAP UI中我得到空指针异常。
<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>
我试过
<api:resourceKey xsi:nil="true" ></api:resourceKey>
获得相同的空指针异常。
您能指导一下解决问题吗?
提前致谢。
答案 0 :(得分:1)
我认为你不必在这里传递null
。 AFAIK,Web服务代码在处理NullPointerException
请求期间抛出SOAP
。试着找出原因是什么?并执行null
检查或更改逻辑以防止它。