You need to sign in to do that
Don't have an account?
Content is not allowed in prolog. SOAP error
I'm currently trying to send a soap message to logon to my salesforce application. I send the following message:
<?xml version="1.0" encoding="utf-16"?>
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<soap:Body>
<login xmlns="urn:enterprise.soap.sforce.com">
<username />
<password />
</login>
</soap:Body>
</soap:Envelope>
I get the following reply:
<?xml version="1.0" encoding="utf-16"?>
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
<soapenv:Body>
<soapenv:Fault>
<faultcode>soapenv:Client</faultcode>
<faultstring>Content is not allowed in prolog.</faultstring>
</soapenv:Fault>
</soapenv:Body>
</soapenv:Envelope>
I'm using a webservice test tool called webstudio (downloaded from gotdotnet). It allows me to invoke the 'login' webservice via a .net proxy called which works fines, but when I use it to invoke the 'login' method via http soap request it fails as above.
Please can anyone explain why salesforce is returning this error. Can anyone send me a complete soap request that will allow me to call the 'login' method, as I'm guessing salesforce doesn't like something in the soap I'm sending it.
Thanks very much in advance for any help.
I was getting the same error on a possibly related problem. I was calling out to a third party REST API from Salesforce. My XML data worked fine when POSTing to the EndPoint from a REST client tool (Postman plugin for Chrome), but I was forever getting "Content is not allowed in prolog" when calling out from Salesforce. After endlessly faffing with character encoding settings I found that the thing that made the difference was setting the content-length header which I'd missed. (I found I'd done this by comparing the request formed in the REST client using Fiddler with what I was doing in the Apex class calling out).
Here's what worked for me (I know you're calling in to Salesforce but it may work):
Exception handling etc. omitted.
Hope that helps someone.
Ray
What language is this?
C# does not like "
"
Tried Content.Headers.Add("Content-length", loginText.Length.ToString()); but then the error is:
"Bytes to be written to the stream exceed the Content-Length bytes size specified"