0

I'm dealing with a problem of connecting to web-service with RPC/encoded WSDL file to my Java/Spring service. I cannot change this WSDL.

I figured out that I have to use Apache Axis 1.4 to create client (according to this problem: https://dzone.com/articles/wsdltojava-error-rpcencoded ).

Then I had problem with login/password/api_key parameters with such message:

<message name="login_message">
   <part name="login" type="xsd:string"/>
   <part name="password" type="xsd:string"/>
   <part name="api_key" type="xsd:int"/>
</message>

Error Element 'api_key': '' is not a valid value of the atomic type 'xs:int'

I solved this problem by adding:

webapi_locator.getEngine().setOption("sendMultiRefs", Boolean.FALSE);

Now I can login and fetch some data from this service but I cannot pushed messages with null arguments like:

<message name="add_offer_input">
   <part name="session" type="xsd:string"/>
   <part name="category_id" type="xsd:int"/>
   <part name="offer" type="tns:offer"/>
</message>

where offer is defined as:

<xsd:complexType name="offer">
   <xsd:all>
     <xsd:element name="price" type="xsd:float" minOccurs="0" maxOccurs="1"/>
     <xsd:element name="price_m2" type="xsd:int" minOccurs="0" maxOccurs="1"/>
   [...]
   </xsd:all>
</xsd:complexType>

Now I am getting exception like this one:

org.apache.axis.AxisFault: Wrong parameters input xml
Element 'price': '' is not a valid value of the atomic type 'xs:int'. line: 1 column: 0'
        at org.apache.axis.message.SOAPFaultBuilder.createFault(SOAPFaultBuilder.java:222) ~[axis-1.4.jar:na]

I have already tried setting

elemField.setNillable(false); 

to

elemField.setNillable(true); 

in Offer.java.

I am creating Offer message in following way:

Offer offer = new Offer(null,null);

I will be very gratefull for found solution for this error. I don't need to stick with axis 1.4 - any other solution which letting me to connect to this service via SOAP with be usefull for me. Thank you very much for help!

1 Answers1

1

You are probably missing the nillable="true" attribute in your WSDL.

The WSDL should look something similar to below:

..
<xsd:element name="price" type="xsd:float" nillable="true" minOccurs="0" maxOccurs="1"/>
..

nillable="true" allows null arguments to be passed. Java2WSDL using Axis 1.4 doesn't do it, as the axis code method writeWrappedParameter() in org/apache/axis/wsdl/fromJava/Types.java doesn't have it.

More info on bug: https://issues.apache.org/jira/browse/AXIS-243

CodeMouse92
  • 6,840
  • 14
  • 73
  • 130
akhil_naik
  • 11
  • 2