gpt4 book ai didi

wcf - 让 WCF 识别传入的 SOAP 请求

转载 作者:行者123 更新时间:2023-12-04 13:40:31 26 4
gpt4 key购买 nike

我正在尝试编写一个 C# 应用程序来接收 eBay 通知,这些通知作为 SOAP 通过 HTTP 发送。我收到的通知正常,但无法将它们传递到我的 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 服务接口(interface)是:

[ServiceContract(Namespace="http://developer.ebay.com/notification")]
public interface Iebaynotification
{
[OperationContract]
void ItemListed(ItemType item);
}

最佳答案

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

您可以让自托管的 WCF 服务(例如在 Windows NT 服务中)监听给定的端点 URL,或者您可以进行基于消息的激活,例如 IIS/WAS,它会捕获传入消息并通过它交给 WCF 进行处理。

基本上,您需要在 WCF 服务类中实现该服务契约,然后您需要托管/部署该 WCF 服务,使其能够处理传入的消息。

但最重要的是:因为它是 SOAP 消息,您不能使用 webHttpBinding,它是用于 WCF REST 服务的绑定(bind)。您需要使用 basicHttpBindingwsHttpBinding 之类的东西。

关于wcf - 让 WCF 识别传入的 SOAP 请求,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3849452/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com