我正在开发一个wsdl webservice来使用来自外部设备的呼叫 Web服务是用C#编写的.NET Framework 3.5,我们使用VS2012 我的问题是来自设备的调用是在soapaction中使用没有名称空间的头发送的。
来自设备的示例呼叫:
POST http://10.32.4.138/wscheckbadge/badge.asmx HTTP/1.1
Host: 10.32.4.138
Connection: keep-alive
Keep-Alive: 300
Content-Type: text/xml;charset=UTF-8
Content-Length: 547
SOAPACTION : "heartBeat"
<?xml version="1.0" encoding="utf-8"?><soapenv:Envelope
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:txn="http://timeAttnHost.mydomain.com"
xmlns:xsd="http://timeAttnHost.mydomain.com/xsd"><soapenv:Header /><soapenv:Body><txn:heartBeat
soapenv:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"><txn:timestamp
xsi:type="xsi:long">1381504799</txn:timestamp><txn:terminalId
xsi:type="xsi:string">PT65-9410</txn:terminalId></txn:heartBeat></soapenv:Body></soapenv:Envelope>
对此我们收到此错误:
“服务器无法识别HTTP标头SOAPAction的值: 心跳“。
在Fiddler中,我编写了同样的电话,但更改了soapaction:
SOAPACTION : "http://timeAttnHost.mydomain.com/heartBeat"
这传递没有错误。
这是我的代码:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Services;
namespace WSCheckBadge
{
[WebService(Namespace = "http://timeAttnHost.mydomain.com")]
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
[System.ComponentModel.ToolboxItem(false)]
// To allow this Web Service to be called from script, using ASP.NET AJAX, uncomment the following line.
[System.Web.Script.Services.ScriptService]
public class Badge : System.Web.Services.WebService
{
private CheckBadge.Badges badges = null;
[WebMethod]
public CheckBadge.PayterTxnResponse heartBeat(long timestamp, string terminalid)
{
if (badges == null)
badges = new CheckBadge.Badges(Properties.Settings.Default.XamConnectionString);
return badges.heartBeat(timestamp, terminalid);
}
}
}
我无法改变设备进行调用的方式,否则我会在soapaction中添加命名空间。
有没有办法让我的网络服务消费这个电话?