首页 > 解决方案 > 如何从 .netcore 中的 wsdl 中删除方法名称

问题描述

我正在尝试从删除的 wsdl 中获取方法名称。我参考了许多 stackoverflow 查询并尝试使用 MessageContract(IsWrapped=false) 并在 ServiceContract 和 OperationContract 上设置以下内容

[XmlSerializerFormat(Use = OperationFormatUse.Literal, Style = OperationFormatStyle.Document, SupportFaults = true)]

但仍然没有运气,方法名称来自 SoapUI 中的肥皂请求,如下所示:

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:tem="http://tempuri.org/" xmlns:the="http://schemas.datacontract.org/2004/07/xx.xxx.xxxx.xxxx">
   <soapenv:Header/>
   <soapenv:Body>
      <tem:GetResult> <!--need to remove this-->
         <!--Optional:-->
         <tem:Pet>
            <!--Optional:-->
            <the:Name>?</the:Name>
         </tem:Pet>
      </tem:GetResult> <!--need to remove this-->
   </soapenv:Body>
</soapenv:Envelope>


[ServiceContract]
[XmlSerializerFormat(Use = OperationFormatUse.Literal, Style = OperationFormatStyle.Document, SupportFaults = true)]
interface IPetService
{

    [OperationContract]
    [XmlSerializerFormat(Use = OperationFormatUse.Literal, Style = OperationFormatStyle.Document, SupportFaults = true)]
    string GetResult(Pet test);
}

[MessageContract(IsWrapped = false)]
public class Pet
{
    [MessageBodyMember]
    public string Name { get; set; }
}

.net core 3.1 中的项目并使用soapcore 包。

任何建议将不胜感激?谢谢。

标签: c#

解决方案


推荐阅读