在wcf服务中获取body xml c# [英] Get body xml in wcf service c#
本文介绍了在wcf服务中获取body xml c#的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我需要获取传入请求的机身标签给我的WCF服务。但我得到了STREAM。
public string GetCountryDetails( string xmlstring)
{
try
{
string bodyxml = OperationContext.Current.RequestContext.RequestMessage.Tostring();
}
catch (例外情况)
{
}
}
我的尝试:
public string GetCountryDetails(string xmlstring)
{
try
{
string bodyxml = OperationContext.Current.RequestContext.RequestMessage .Tostring();
}
catch(例外情况)
{
}
}
O / p: -
< span class =code-keyword>< soapenv:Envelope xmlns:soapenv = http://schemas.xmlsoap.org/soap / envelope / >
< soapenv:标题 >
< span class =code-keyword>< soapenv:mustUnderstand = 1 xmlns = http: //schemas.microsoft.com/ws/2005/05/addressing/none\"> http:// localhost:51047 / Service1.svc < span class =code-keyword>< /到 >
< 操作 soapenv:mustUnderstand = 1 xmlns = http://schemas.microsoft.com/ws/2005/05/addressing/none > urn:IService1 / GET_COUNTRY_DETAILS < / Action >
< / soapenv:标题 >
< soapenv:Body > ... stream ... < / soapenv:正文 >
< / soapenv:Envelope >
解决方案
请试试这个。
public string GetCountryDetails( string xmlstring)
{
尝试
{
string bodyxml = OperationContext.Current.RequestContext.RequestMessage.GetBodyAttribute ( attributename, 命名空间跨度>);
}
catch (例外情况)
{
}
}
Hi,
I need to get body tags of incoming request to my WCF service. But i am getting as STREAM.
public string GetCountryDetails(string xmlstring)
{
try
{
string bodyxml = OperationContext.Current.RequestContext.RequestMessage.Tostring();
}
catch(Exception ex)
{
}
}
What I have tried:
public string GetCountryDetails(string xmlstring)
{
try
{
string bodyxml = OperationContext.Current.RequestContext.RequestMessage.Tostring();
}
catch(Exception ex)
{
}
}
O/p:-
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
<soapenv:Header>
<To soapenv:mustUnderstand="1" xmlns="http://schemas.microsoft.com/ws/2005/05/addressing/none">http://localhost:51047/Service1.svc</To>
<Action soapenv:mustUnderstand="1" xmlns="http://schemas.microsoft.com/ws/2005/05/addressing/none">urn:IService1/GET_COUNTRY_DETAILS</Action>
</soapenv:Header>
<soapenv:Body>... stream ...</soapenv:Body>
</soapenv:Envelope>
解决方案
Hi,
Please try this.
public string GetCountryDetails(string xmlstring) { try { string bodyxml = OperationContext.Current.RequestContext.RequestMessage.GetBodyAttribute("attributename","namespace"); } catch (Exception ex) { } }
这篇关于在wcf服务中获取body xml c#的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文