[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);
}