c#调用ws接口问题
接口
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ewel="xxx">
<soapenv:Header/>
<soapenv:Body>
<ewel:BS05007>
<ewel:input>?</ewel:input>
</ewel:BS05007>
</soapenv:Body>
</soapenv:Envelope>
soapui 测试
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
<soapenv:Body>
<NS1:BS05007Response xmlns:NS1="xxx">
<NS1:output>
<response>
<errorCode>1</errorCode>
<errorMsg>请验证传入参数</errorMsg>
</response>
</NS1:output>
</NS1:BS05007Response>
</soapenv:Body>
</soapenv:Envelope>
vs添加web引用
public class Class1
{
WebReference.Ewell_S50HttpService service = new WebReference.Ewell_S50HttpService();
public string aaa(string xml) {
WebReference.BS05007 bs=new WebReference.BS05007();
bs.input=xml;
String ss= service.BS05007(bs).output;//这一步直接报错
return ss;
}
}
//调用
ClassLibrary1.Class1 cl = new ClassLibrary1.Class1();
var a = cl.aaa(c);
报错信息:
public class Class1
{
WebReference.Ewell_S50HttpService service = new WebReference.Ewell_S50HttpService();
public string aaa(string xml) {
WebReference.BS05007 bs=new WebReference.BS05007();
bs.input=xml;
String ss= service.BS05007(bs).output;
return ss;
}
}
第二种调用
public class S50Help
{
S50.Ewell_S50Client client = null;
public string sendbs5007(string xml)
{
client = new S50.Ewell_S50Client(new BasicHttpBinding(), new EndpointAddress("xxxx"));
S50.BS05007 bs5007 = new S50.BS05007();
bs5007.input = xml;
XmlDocument doc=new XmlDocument();
var aa=client.BS05007(bs5007).output;
doc.LoadXml(aa.ToString());
return doc.ToString();
}
}
//调用
Ewell_S50_Services.S50Help h = new Ewell_S50_Services.S50Help();
var s= h.sendbs5007(c);
“System.ServiceModel.CommunicationException”类型的第一次机会异常在 mscorlib.dll 中发生
其他信息: 对操作“BS05007”的回复消息正文进行反序列化时出错。