删除XML消息

时间:2018-06-13 06:40:09

标签: javascript http post xmlhttprequest

我尝试在javascript(在node.js上运行)客户端脚本和WCF(SOAP)服务之间创建通信超过一周。

通信是:XML,POST方法

xmlhttp.setRequestHeader('Content-Type', 'text/xml; charset=utf-8');

我发送给服务的URL和XML定义为:

soapRequest('http://winserver:8735/ReportsListsService', 
    `<?xml version="1.0" encoding="UTF-8"?><s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/">
    <s:Header>
      <Action s:mustUnderstand="1" xmlns="http://schemas.microsoft.com/ws/2005/05/addressing/none">http://tempuri.org/IReportsListsService/GetClients</Action>
    </s:Header>
    <s:Body>
      <GetClients xmlns="http://tempuri.org/" />
    </s:Body>
  </s:Envelope>`);

这是我的服务,目前正在尝试调用最简单的方法GetClients

using System;
using System.Collections.Generic;
using System.ServiceModel;
using System.ServiceModel.Web;
using tt4t.Dispatching.ApplicationServer.Data.CommonData;

namespace tt4t.Dispatching.ApplicationServer.Data.Reports.Lists
{
    [ServiceContract]
    public interface IReportsListsService : IMicroservice
    {
  [OperationContract]
        IEnumerable<Client> GetClients();
    }
}

但是在Chrome调试控制台中出现此错误

<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/"><s:Body><s:Fault><faultcode>s:Client</faultcode><faultstring xml:lang="en-US">The incoming message contains a SOAP header representing the WS-Addressing 'Action', yet the HTTP transport is configured with AddressingVersion.None.  As a result, the message is being dropped.  If this is not desired, then update your HTTP binding to support a different AddressingVersion.</faultstring></s:Fault></s:Body></s:Envelope>

此错误响应我的xml请求的这一行

   <s:Header>
              <Action s:mustUnderstand="1" xmlns="http://schemas.microsoft.com/ws/2005/05/addressing/none">http://tempuri.org/IReportsListsService/GetClients</Action>
   </s:Header>

完整代码:here

1 个答案:

答案 0 :(得分:0)

缺少问题

xmlhttp.setRequestHeader('SOAPAction', "http://tempuri.org/IReportsListsService/GetClients");