try
{
string xml = XMLExporter.OrderToXML(order);
WebRequest request = WebRequest.Create("http://localhost:60159/intranet/webservice/OrderService.asmx/ReceiveOrder");
request.Method = "POST";
byte[] byteArray = Encoding.UTF8.GetBytes(xml);
request.ContentType = "application/xml";
request.ContentLength = byteArray.Length;
Stream dataStream = request.GetRequestStream();
dataStream.Write(byteArray, 0, byteArray.Length);
dataStream.Close();
WebResponse webResponse = request.GetResponse(); // ERROR HERE
}
catch // 500 error
{
return false;
}
return true;
网络配置:
<system.serviceModel>
<bindings>
<basicHttpBinding>
<binding name="ReceiveOrder" />
</basicHttpBinding>
</bindings>
<client>
<endpoint address="http://localhost:60159/intranet/webservice/OrderService.asmx" binding="basicHttpBinding" bindingConfiguration="ReceiveOrder" contract="OrderService.ReceiveOrder" name="ReceiveOrder" />
</client>
<webServices>
<protocols>
<add name="HttpGet"/>
<add name="HttpPost"/>
</protocols>
</webServices>
“远程服务器返回错误:(500)内部服务器错误。”
当我直接从代码中调用该方法时,它工作正常!
任何人都可以阐明这个错误吗?