代码之家  ›  专栏  ›  技术社区  ›  sipsorcery

让WCF识别传入的SOAP请求

  •  3
  • sipsorcery  · 技术社区  · 15 年前

    我正在尝试编写一个C#应用程序来接收通过HTTP以SOAP形式发送的eBay通知。我正在接收通知,但我无法将它们传递到我的WCF服务。我需要在WCF服务配置上做什么才能识别传入的SOAP请求?我正在使用webHttpBinding和WCF服务。

    SOAP请求是:

    POST /paypal/ebaynotification.svc HTTP/1.0
    Host: myserver.com
    Content-Type: text/xml;charset=utf-8
    SOAPAction: "http://developer.ebay.com/notification/ItemListed"
    Content-Length: 6610
    X-Original-Client: 10.71.29.83
    Via: 1.0 sjcproxy10b:8081 (squid)
    Cache-Control: max-age=86400
    Connection: keep-alive
    
    <?xml version="1.0" encoding="UTF-8"?>
    <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
     <soapenv:Header>
      <ebl:RequesterCredentials soapenv:mustUnderstand="0" xmlns:ns="urn:ebay:apis:eBLBaseComponents" xmlns:ebl="urn:ebay:apis:eBLBaseComponents">
       <ebl:NotificationSignature xmlns:ebl="urn:ebay:apis:eBLBaseComponents">RnvpyFAXc9Duo0W+/Mk68g==</ebl:NotificationSignature>
      </ebl:RequesterCredentials>
     </soapenv:Header>
     <soapenv:Body>
          ....
         </soapenv:Body>
       </soapenv:Envelope>
    

    我的WCF服务接口是:

    [ServiceContract(Namespace="http://developer.ebay.com/notification")]
    public interface Iebaynotification
    {
        [OperationContract]
        void ItemListed(ItemType item);
    }
    
    2 回复  |  直到 6 年前
        1
  •  2
  •   marc_s    15 年前

    您需要一些东西来“捕获”传入的SOAP请求,并启动WCF类来处理它。

    您可以让一个自托管WCF服务(例如,在Windows NT服务中)监听给定的端点URL,也可以让一个基于消息的激活,比如IIS/WAS,它将捕获传入消息并将其传递给WCF进行处理。

    因此,基本上,您需要在WCF服务类中实现该服务契约,然后您需要以这样一种方式托管/部署该WCF服务,即传入消息将由它处理。

    但最重要的是: 因为这是一条SOAP消息,所以 不能 使用 webHttpBinding 这是用于WCF REST服务的绑定。你需要使用类似于 basicHttpBinding wsHttpBinding .

        2
  •  0
  •   larsw    15 年前

    如果eBay公开了一个SOAP端点,我猜他们已经公开了一个描述回调服务的WSDL文档。您可以使用svcutil。exe命令行工具生成正确的WCF契约/C#接口,您需要在服务实现中实现该接口来处理所描述的SOAP消息。请参阅易趣的API文档。。。

    推荐文章