我需要创建一个Web服务来接收客户用来向各种系统发送信息的SOAP请求,我所拥有的只是一个示例xml负载。我已经使用创建了一个测试WCF Web服务 https://www.c-sharpcorner.com/article/create-simple-wcf-service-and-host-it-on-console-application/ 并且打算按照
的方式创建一个类while (n >= 1) {
System.out.print("Enter a non-negative integer (-1 to quit) : ");
n = keyboard.nextInt(); //Read
if (n == 0) { //Evaluate
System.out.print(1); //Remove (n = 1) as suggested by @Aaron in the comments below, it is weird and may cause strange issues in larger programs
} else if (n == -1) { //Evaluate
System.out.print("Goodbye!");
break; //Exit
} else { //Calculate
factorial = factorial(n);
System.out.println(n + "! = " + factorial);
}
}
并将其托管在控制台App中。然后我在谷歌上搜索了public class WebServiceSOAP : IWebServiceSOAP
{
public string SetProductInfo(string strSOAPRequest)
{
// Parse the xml received, validate etc
string response = ParseSOAPData(strSOAPRequest);
// response depends on if data passes validation or not.
return response;
}
}
类,但我不清楚它是如何适应普通的WCF服务的,例如这里的例子
https://msdn.microsoft.com/en-gb/library/ms819935.aspx
似乎使用SoapService
代替Microsoft.Web.Services2/3
这是否意味着我可以使用相同的方法来设置我的网络服务,就像我之前所遵循的示例一样?包括App.config。 System.ServiceModel
的示例似乎与我遵循的WCF服务的设置完全不同。我显然遗漏了一些东西。我无法从界面和System.ServiceModel
继承,而且我会拥有一个SoapService
和[OperationContract]
属性的函数。
看起来我可以收到SOAPEnvelope并使用[SoapMethod]
获取正文/有效负载,但我不清楚它是否返回xml或者主体是否仍然具有所有<替换为<我可以只取SoapEnvelope.GetBodyObject
的结果并解析xml吗?