-2
    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;

Web.Config:

  <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>

"The remote server returned an error: (500) Internal Server Error."

when i call the method directly from the code it works fine!

Can anyone shed a light on this error?

pnuts
  • 58,317
  • 11
  • 87
  • 139
Matheus Simon
  • 668
  • 11
  • 34
  • 2
    You haven't said what "this error" is which makes it hard to shed light on it. Rather than just "rambling" you should have taken the opportunity to provide more details. Please read http://tinyurl.com/so-list – Jon Skeet Aug 09 '13 at 12:36
  • So I guess you have an error ? What is the error exactly ? – Simon Rapilly Aug 09 '13 at 12:36
  • is that a wee bit better? – Matheus Simon Aug 09 '13 at 12:46
  • so its all about nagging huh skeet? you either can or cannot help. – Matheus Simon Aug 09 '13 at 13:00
  • "Users with less than 10 reputation can't answer their own question for 8 hours after asking. You can answer in 5 hours. Until then please use comments, or edit your question instead." oh my love for this site is very deep! so deep I sometimes cant find it. – Matheus Simon Aug 09 '13 at 15:04

1 Answers1

1

If you get à http error 500 it means that it's the server part that throw so you should have a look inside the method ReceiveOrder in OrderService.asmx.

To resume it's not a problem from the caller, but from the receiver.

Pit Ming
  • 401
  • 2
  • 5
  • 13