Tell me more ×
Stack Overflow is a question and answer site for professional and enthusiast programmers. It's 100% free, no registration required.

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 ?

share|improve this question

1 Answer

up vote 0 down vote accepted

"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
share|improve this answer
i've returnedContentType to "plain" and see the error but how to fix it ? you can see my error in UPDATED my question – user2265231 14 hours ago
As you can see now in the 'text' field, the problem is occurring on your back end and not on WL. The backend returns text error message and this is the reason WL server failed to parse it as XML in the first place. According to the error message "Getperson Web Service method name is not valid". Make sure that you're calling the correct URL. – Anton 12 hours ago
OMG i've seen some thing worng in my path,thanks you so much – user2265231 12 hours ago

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.