问题描述 投票:0回答:0
我的服务:

[ServiceContract(Namespace = "https://myNamespace.com")] public class SampleService : ISampleService { public string Test(string s) { Console.WriteLine("Test Method Executed!"); return s; } public void XmlMethod(XElement xml) { Console.WriteLine(xml.ToString()); } public MyCustomModel TestCustomModel(MyCustomModel customModel) { return customModel; } }

我的服务接口:

[ServiceContract] public interface ISampleService { [OperationContract] string Test(string s); [OperationContract] void XmlMethod(System.Xml.Linq.XElement xml); [OperationContract] MyCustomModel TestCustomModel(MyCustomModel inputModel); }

我发送的肥皂是:

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns="https://myNamespace.com"> <soapenv:Header/> <soapenv:Body> <ns:TestCustomModel> <userName>USERNAME</userName> <password>PASSWORD</password> <orgId>123</orgId> <poolId>1234</poolId> <cycleStartDate>2023-01-01</cycleStartDate> </ns:TestCustomModel> </soapenv:Body> </soapenv:Envelope>
但是我得到了这个错误:


基于我能找到的东西,我相信我正在在正确的位置设置名称空间,但仍然期望tempuri.org

我需要将命名空间声明从我的服务转移到其接口。
我的服务:

public class SampleService : ISampleService { public string Test(string s) { Console.WriteLine("Test Method Executed!"); return s; } public void XmlMethod(XElement xml) { Console.WriteLine(xml.ToString()); } public MyCustomModel TestCustomModel(MyCustomModel TestCustomModel) { return TestCustomModel; } }

我的服务接口:
[ServiceContract(Namespace = "https://myNamespace.com")]
    public interface ISampleService
    {
        [OperationContract]
        string Test(string s);

        [OperationContract]
        void XmlMethod(System.Xml.Linq.XElement xml);

        [OperationContract]
        MyCustomModel TestCustomModel(MyCustomModel inputModel);
    }

enter image description here

c# xml .net-core soap
最新问题
© www.soinside.com 2019 - 2025. All rights reserved.