I'm trying to access a SOAP web service of a data vendor. The server is written in Java. I'm accessing it from Perl. Due to some specialty, I have to send original http requests myself instead of using SOAP Lite package.
The client is working fine. I can call most methods, and the response I get also looks good, which means things like request, response and namespace are all good. However, there is one method that I have trouble with. The wsdl of its request data type is as below:
<xs:element name="method1">
<xs:complexType>
<xs:sequence>
<xs:element minOccurs="0" name="xmlContent" nillable="true" type="xs:string"/>
</xs:sequence>
</xs:complexType>
</xs:element>
The unique part of this method is that it accepts a string element, xmlContent, which is actually xml content. And here is my request:
<?xml version="1.0" encoding="UTF-8"?>
<SOAP-ENV:Envelope xmlns:xsi="http://www.w3.org/1999/XMLSchema-instance" xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/" xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/1999/XMLSchema" SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
<SOAP-ENV:Body>
<namesp1:method1 xmlns:namesp1="http://vendor.com">
<xmlContent xsi:type="xsd:string">
<?xml version="1.0" encoding="UTF-8"?>
<product id="ABC" type="CSV">
<columns>
<column name="DATE" format="yyyymmdd" />
<column name="COUNTRY" format="DESC"/>
</columns>
</product>
</xmlContent>
</namesp1:method1>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>
I saved the request in a file, and read the file into Perl, and send the http post request. The fault string I got is: Validation Error(s): Content is not allowed in prolog
.
I googled, and it seems to be Java couldn't recognize the 2nd <?xml version="1.0" encoding="UTF-8"?>
line. I tried removing that line, but I got a different error: premature end of file
My questions: Am I putting the xml content part the right way? What's causing the error? How can I fix it?