我有 1 个带有 .Net 的网络服务,并返回如下值:
<People>
<Person Name="Nick"/>
<Person Name="Nick"/>
</People>
而且我还按照本教程在我的 worklight 应用程序链接中调用 webservice 。但是我遇到了一些错误:
{
"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": [
]
}
这是 myadapert.xml 中的配置:
<protocol>http</protocol>
<domain>localhost</domain>
<port>3923</port>
<procedure name="getperson"/>
在 myadapter-impl.js 的配置中:
function getperson() {
var input = {
method : 'get',
returnedContentType : 'xml',
path : "/Service1.asmx/MyMethod"
};
return WL.Server.invokeHttp(input);
}
谢谢你的帮助 !
更新
当我将“returnedContentEncoding”xml 更改为 plain.i 时出现此错误:
{
"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": [
]
}
这里有什么问题?