Question

i've 1 webservice with .Net and return value like that:

<People>
<Person Name="Nick"/>
<Person Name="Nick"/>
</People>

And i've also folow this tutorial to call webservice in my worklight app link .But i've got some error:

{
   "errors": [
      "Content is not allowed in prolog.",
      "Failed to parse the payload from backend (procedure: HttpRequest)"
   ],
   "info": [
   ],
   "isSuccessful": false,
   "responseHeaders": {
      "Cache-Control": "private",
      "Connection": "Close",
      "Content-Length": "457",
      "Content-Type": "text\/plain; charset=utf-8",
      "Date": "Thu, 13 Jun 2013 02:47:56 GMT",
      "Server": "ASP.NET Development Server\/10.0.0.0",
      "X-AspNet-Version": "2.0.50727"
   },
   "responseTime": 0,
   "statusCode": 500,
   "statusReason": "Internal Server Error",
   "totalTime": 141,
   "warnings": [
   ]
}

Here is config in myadapert.xml:

<protocol>http</protocol>
<domain>localhost</domain>
<port>3923</port>
<procedure name="getperson"/>

and here in config in myadapter-impl.js:

function getperson() {
    var input = {
            method : 'get',
            returnedContentType : 'xml',          
            path : "/Service1.asmx/MyMethod"
        };
        return WL.Server.invokeHttp(input);
}

Thanks for any help !

UPDATED

when i've change "returnedContentEncoding" xml to plain.i've got this error:

{
   "errors": [
   ],
   "info": [
   ],
   "isSuccessful": true,
   "responseHeaders": {
      "Cache-Control": "private",
      "Connection": "Close",
      "Content-Length": "457",
      "Content-Type": "text\/plain; charset=utf-8",
      "Date": "Thu, 13 Jun 2013 02:28:38 GMT",
      "Server": "ASP.NET Development Server\/10.0.0.0",
      "X-AspNet-Version": "2.0.50727"
   },
   "responseTime": 281,
   "statusCode": 500,
   "statusReason": "Internal Server Error",
   "text": "System.InvalidOperationException: Getperson Web Service method name is not valid.\n   at System.Web.Services.Protocols.HttpServerProtocol.Initialize()\n   at System.Web.Services.Protocols.ServerProtocol.SetContext(Type type, HttpContext context, HttpRequest request, HttpResponse response)\n   at System.Web.Services.Protocols.ServerProtocolFactory.Create(Type type, HttpContext context, HttpRequest request, HttpResponse response, Boolean& abortProcessing)",
   "totalTime": 313,
   "warnings": [
   ]
}

what's wrong here ?

Was it helpful?

Solution

"Content is not allowed in prolog" error is usually thrown by parser when your XML contains some characters before the first <?xml.....> element.

Two options here:

  1. Try changing returnedContentType to "plain" so returned XML will not be parsed and you can see what exactly might be causing the problem
  2. Try manually setting returnedContentEncoding property of invocation options
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top