这是我的XML响应soap(c#“。asmx中的WS”):
<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<soap:Body>
<TestrequestResponse xmlns="http://tempuri.org/">
<TestrequestResult>
<name>filename.xml</name>
<code>30</code>
</TestrequestResult>
</TestrequestResponse>
</soap:Body>
</soap:Envelope>
我希望得到这样的回复:
<?xml version="1.0" encoding="utf-8"?>
<Response result=”KO”>
<name>filename.xml</name>
<code>30</code>
</Response>
我该怎么做?
编辑:
[WebMethod]
public Response Testrequest()
{
var r = new Response();
r.name = "30";
r.code = "0";
return r;
}
对象响应:
public class Response
{
public string name { get; set; }
public string code { get; set; }
}
答案 0 :(得分:1)
您可以执行SOAP消息格式化(https://msdn.microsoft.com/en-us/library/dkwy2d72%28v=vs.100%29.aspx),但创建一个返回所需格式而不是调用SOAP服务的简单网页会更容易。