我有一个可以返回带有标签的 xml 的函数,但我想获取我传递的字符串,而不是正文中的任何其他标签,我可以编辑该函数。
[ServiceBehavior]
public class HelloService : IHelloService
{
public string Greet(string name)
{
return "Hello ," + name;
}
}
public class ConsoleMessageInspector : IClientMessageInspector, IDispatchMessageInspector
{
public Message CreateMessage(Message message)
{
MessageBuffer buffer = message.CreateBufferedCopy(Int32.MaxValue);
var messageCopy = buffer.CreateMessage();
Console.WriteLine(messageCopy.ToString());
return buffer.CreateMessage();
}
}
XML 实际上我只想要正文中的字符串,没有其他标签是可能的..
{<s:Envelope xmlns:s="schemas.xmlsoap.org/soap/envelope/">; <s:Header>
<Action s:mustUnderstand="1" xmlns="schemas.microsoft.com/ws/2005/05/addressing/none">http:/…;
</s:Header> <s:Body>
<GreetResponse xmlns="tempuri.org/">; <GreetResult>Hello ,wasif</GreetResult>
</GreetResponse> </s:Body> </s:Envelope>}