【发布时间】:2018-01-05 22:59:27
【问题描述】:
我正在尝试使用 ebay 及其 SDK 接收通知。我设法找到了一个使用 ASP.net Web 服务的工作示例。但是,我希望能够在 Azure 上托管它并将其移动到 WCF 似乎是一个合适的解决方案。我已经尝试过这样做,我得到的最接近的是得到一个xml serializer 错误,如下所示:
服务器在处理请求时遇到错误。异常消息是“无法使用 XmlSerializer 反序列化具有根名称“信封”和根命名空间“http://schemas.xmlsoap.org/soap/envelope/”的 XML 正文(用于操作“GetOutBid”和合同(“IReceiver”、“urn:ebay:apis:eBLBaseComponents”)) .确保将 XML 对应的类型添加到服务的已知类型集合中。'
从我在网上看到的情况来看,这可能与数据合同的设置方式有关 - 我是 WCF 新手,所以不确定!
以下是我尝试放入 WCF 的 Web 服务的工作原理:
[WebMethod()]
[System.Web.Services.Protocols.SoapHeaderAttribute("RequesterCredentials", Direction = System.Web.Services.Protocols.SoapHeaderDirection.In)]
[System.Web.Services.Protocols.SoapDocumentMethodAttribute(Action = "http://developer.ebay.com/notification/OutBid", Use = System.Web.Services.Description.SoapBindingUse.Literal, ParameterStyle = System.Web.Services.Protocols.SoapParameterStyle.Bare)]
public void OutBid(GetItemResponseType GetItemResponse)
{
if (CheckSignature(GetItemResponse.Timestamp))
{
//Implement your own business logic here
}
else
{
//Implement your own business logic here
}
LogRequest(Server.MapPath("files/OutBid_" + GetItemResponse.Item.ItemID + "_" + GetItemResponse.Item.SellingStatus.BidCount.ToString() + "_" + GetItemResponse.CorrelationID + ".xml"));
}
public class student { public int rollno { get; set; } }
public class school { public student obj { get; set; } }
class Program
{
static void Main(string[] args)
{
school obje = new school(); obje.obj.rollno = 2; Console.WriteLine(obje.obj.rollno);
}
}
【问题讨论】: