嗨,我正在与邮递员请求wcf wService Web服务,我也收到此错误,我的同事也收到了使用angular和.Net平台的响应200, PS:我想在android studio中实现此请求,所以我需要先查看响应
这是我的要求
<x:Envelope xmlns:x="http://schemas.xmlsoap.org/soap/envelope/" xmlns:tem="http://tempuri.org/" xmlns:san="http://schemas.datacontract.org/2004/07/Sanay.Suip.Library">
<x:Header/>
<x:Body>
<tem:QueryMessage>
<tem:messageSet>
<san:ActionId>?</san:ActionId>
<san:Ip>::1</san:Ip>
<san:Parameters>
<san:Parameter>
<san:Name>Username</san:Name>
<san:Value>tipex</san:Value>
</san:Parameter>
<san:Parameter>
<san:Name>Password</san:Name>
<san:Value>123456</san:Value>
</san:Parameter>
</san:Parameters>
<san:Title>Authenticate</san:Title>
<san:Token>?</san:Token>
<san:Username>tipex</san:Username>
</tem:messageSet>
</tem:QueryMessage>
</x:Body>
这是我的答复
<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/">
<s:Body>
<s:Fault>
<faultcode xmlns:a="http://schemas.microsoft.com/net/2005/12/windowscommunicationfoundation/dispatcher">a:DeserializationFailed</faultcode>
<faultstring xml:lang="en-US">The formatter threw an exception while trying to deserialize the message: There was an error while trying to deserialize parameter http://tempuri.org/:messageSet. The InnerException message was 'Element Value from namespace http://schemas.datacontract.org/2004/07/Sanay.Suip.Library cannot have child contents to be deserialized as an object. Please use XmlNode[] to deserialize this pattern of XML.'. Please see InnerException for more details.</faultstring>
</s:Fault>
</s:Body>
这是.NET请求
private void button1_Click(object sender, EventArgs e)
{
var service = new ServiceHelper();
var msg = new IrptServiceReference.Message();
msg.Username = textBox1.Text;
msg.Title = "Authenticate";
msg.Parameters = new List<IrptServiceReference.Parameter>();
msg.Ip = "::1";
msg.Parameters.Add(new IrptServiceReference.Parameter { Name = "Password", Value = textBox2.Text });
msg.Parameters.Add(new IrptServiceReference.Parameter { Name = "Username", Value = textBox1.Text });
var dt = service.MessageExchange(msg);
if (dt == null) return;
var token = dt[0].Rows[0][0].ToString();
textBox3.Text = token;
}
答案 0 :(得分:0)
缺少您的x:Envelope
结束标记
<x:Envelope xmlns:x="http://schemas.xmlsoap.org/soap/envelope/" xmlns:tem="http://tempuri.org/" xmlns:san="http://schemas.datacontract.org/2004/07/Sanay.Suip.Library">
<x:Header/>
<x:Body>
<tem:QueryMessage>
<tem:messageSet>
<san:ActionId>?</san:ActionId>
<san:Ip>::1</san:Ip>
<san:Parameters>
<san:Parameter>
<san:Name>Username</san:Name>
<san:Value>tipex</san:Value>
</san:Parameter>
<san:Parameter>
<san:Name>Password</san:Name>
<san:Value>123456</san:Value>
</san:Parameter>
</san:Parameters>
<san:Title>Authenticate</san:Title>
<san:Token>?</san:Token>
<san:Username>tipex</san:Username>
</tem:messageSet>
</tem:QueryMessage>
</x:Body>
</x:Envelope>