【问题标题】:SOAP Envelope of BaseClass [duplicate]BaseClass 的 SOAP 信封 [重复]
【发布时间】:2016-08-17 14:53:44
【问题描述】:

我有两门课

public class Person
{
    public String ForeName {get;set;}
    //...
}

public class Customer : Person
{
    public String LastName{get;set;}
    //...
}

如果我现在通过 SOAP 服务返回 Customer,它只会在操作列表的 SOAP 信封示例中显示 LastName。

网络方法:

[WebMethod(MessageName = "getCustomer")]
public Customer GetCustomer()
{
    return new Customer();
}

响应示例:

HTTP/1.1 200 OK
Content-Type: text/xml; charset=utf-8
Content-Length: length

<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
  <soap:Body>
    <getCustomerResponse xmlns="http://tempuri.org/">
      <getCustomerResult>
        <LastName>string</LastName>
      </getCustomerResult>
    </getCustomerResponse>
  </soap:Body>
</soap:Envelope>

注意: 该代码工作正常,WSDL 是正确的。我只对正确的 SOAP 信封感兴趣。

问题: 如何标记Customer 以便它也显示Person 的属性?

我在框架中使用 C# ASP.Net 是 3.5

【问题讨论】:

  • 不,答案下方的评论再次说明了我的问题:“它似乎生成了正确的代码,它只是没有显示在示例中。

标签: c# asp.net web-services soap


【解决方案1】:

正如微软所说,问题是产品中的一个错误: https://connect.microsoft.com/VisualStudio/feedback/details/520200/inherited-properties-do-not-appear-in-soap-sample-on-asmx-file

我在另一个似乎有同样问题的问题中找到了答案。 Inherited properties do not appear in soap sample on asmx file

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2010-09-23
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多