четвер, 13 січня 2011 р.

Groovy Soap Client, Custom Groovy Soap Client, and webservice overloading

It was beautiful winter morning, when I started creating SOAP client to our web-services. I decided to use groovy.net.soap.SoapClient. because of the applciation was written in Groovy language. The examples from official tutorial promise the easy life, so I was wondered when in ten minutes a got completed code which throws exception
XmlSchemaException "Content is not allowed in prolog"
In the line:
proxy = new SoapClient( endpoint )



First of all I checked xml and realized that it's absolutely correct. On the next step I touched: http://www.webservicex.net/CurrencyConvertor.asmx?WSDL
and my code works fine with this URL. So, I started googling...



 and find next page soon http://www.judahfrangipane.com/blog/2006/12/13/content-is-not-allowed-in-prolog/
It has interesting comment I was receiving the same "content not allowed in prolog". I changed the encoding="UTF-8" to encoding="utf-8" and it works.

Huray, the difference between "good" and "bad" WSDL was exactly in it for my case (I checked xml via TcpMon)! Oh no, in the code of WSDL was utf-8... Does it meas Axis convert encoding case itself? sucks! As it was not be possible to configure, I decided to rewrite groovy client. Yeap, SoapClient is opensource and you can reach code, for example on grepcode.com

So, I wrote simple class extends SoapClient that converts xml a bit: it change case for encodeing and the pass processing to org.codehaus.xfire.client.Client
However....
Content is not allowed in prolog
Shit! I was upset... Does it Axis feature? I started checking all wsdl from our project - well, this problem exists only on specific wsdl. The "bad" wsdl has import of external XSD and as result we got two schemes with the same targetNamespce and second is empty. I tuned custom SoapClient to get new functionality then just remove empty scheme... Hurray no more,
Content is not allowed in prolog
BUT! New exception (I believe it was a cause of all issues) - operation reload is forbidden.
If tou check https://issues.apache.org/jira/browse/CXF-2233:
WSDL's with overloaded methods are specifically NOT allowed by the WSI-Basic Profile and the JAX-WS specification.
However Axis (used obn backend) allows operation (web-service) overloading... I believe, it's a good expirience to choose SOAP framwework in the future

Немає коментарів:

Дописати коментар