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

    Question

  • Hello

    I'm must contact a remote service using httpwebrequest and response. this service has two method: ping to test the service and another to get the data i need. I'm using the framework 2.0 and xmlspy to create the soap messages and load them later with an xmldocument object. I test the messages with xmlspy and later i test them with c# code. The ping method works correctly in both cases, while i get the response of the second method sending the message with xmlspy but not sending it by code. 

    Supposing xmlspy generates a correct soap message, i must miss something in my code ( see below)

     

    HttpWebRequest request = (HttpWebRequest)

    HttpWebRequest.Create(@"http://xxxxxxx/B2FleetWCF.svc");

    ASCIIEncoding encoding = new ASCIIEncoding();

    //i need to pass through a local firewall

    request.Credentials = new NetworkCredential(....);

    request.Proxy = new WebProxy(...);

    request.Method = "POST";

    request.Headers.Add("SOAPAction", "http://...../IB2FleetWCF/GetModuleNotTransfered");//or .../Ping

    request.ContentType = "text/xml; charset=utf-8";

    request.Accept = "text/xml";

    XmlDocument doc = new XmlDocument();

    doc.Load(@"C:\....\GetModuleNotTransfered.xml"); //or .../Ping.xml

    System.IO.StreamWriter stOut = new System.IO.StreamWriter(request.GetRequestStream());

    doc.Save(stOut);

    stOut.Close();

    try

    {

    wresp = (HttpWebResponse)request.GetResponse();

    if (wresp.StatusCode == HttpStatusCode.OK)

    {

    using (Stream s = wresp.GetResponseStream())

    {

    Encoding enc = Encoding.GetEncoding("utf-8");

    readStream = new StreamReader(s, enc);

    result = readStream.ReadToEnd();

    s.Close();

    }

    }

    }

    catch (WebException ex)

    {

    StreamReader lettore = new StreamReader(ex.Response.GetResponseStream());

    string valore = lettore.ReadToEnd();

    lettore.Close();

    }

     

    I'm not a big expert of soap and web services, till now i simply added a web reference to my project and worked with it.

    Could you direct me to some article or tutorial and give me some hints about my problem please?

     

    the value of the response stream is

     

    <faultcode xmlns:a="http://schemas.microsoft.com/ws/2005/05/addressing/none">a:ActionNotSupported</faultcode>

      <faultstring xml:lang="en-US">The message with Action 'http://.../GetModuleNotTransfered' cannot be processed at the receiver, due to a ContractFilter mismatch at the EndpointDispatcher. This may be because of either a contract mismatch (mismatched Actions between sender and receiver) or a binding/security mismatch between the sender and the receiver. Check that sender and receiver have the same contract and the same binding (including security requirements, e.g. Message, Transport, None).</faultstring>
     
     
     
     Thank you in advance
     Stefano
     
     
     

     

     

     

    Thursday, January 03, 2008 10:38 AM

Answers

  • In this case, you should consider a plug-in architecture where your main application consumes one of several customer-specific plug-ins. Each plug-in implement the same interface, so your main application could communicate with whichever plug-in is desired.

     

    Each plug-in would be able to use Add Service Reference to consume the particular desired WCF service, or Add Web Reference for ASMX-style services. Your main code would not care.

     

    The main benefit would be that you could cease reinventing the wheel.

     

    Thursday, January 03, 2008 5:52 PM
    Moderator

All replies

  • Is there some reason you can't just add a service reference to your client and use that?

     

    Also, this is clearly a WCF question, so you should ask at http://forums.microsoft.com/MSDN/ShowForum.aspx?ForumID=118&SiteID=1.

    Thursday, January 03, 2008 1:04 PM
    Moderator
  • The reason i cant add the references to the project is that customers are free to use any technology they wish and above all that new customers can be added or removed at any time, so i can't rebuild and redistribute the app every time.

    I'll post to the link . thank you for your answer

    Thursday, January 03, 2008 1:57 PM
  • In this case, you should consider a plug-in architecture where your main application consumes one of several customer-specific plug-ins. Each plug-in implement the same interface, so your main application could communicate with whichever plug-in is desired.

     

    Each plug-in would be able to use Add Service Reference to consume the particular desired WCF service, or Add Web Reference for ASMX-style services. Your main code would not care.

     

    The main benefit would be that you could cease reinventing the wheel.

     

    Thursday, January 03, 2008 5:52 PM
    Moderator
  •  

    Already suggested to the boss: each customer has his own dll implementing the same interface, and load them by reflection. that would simplify a lot my task, since a customer don't even implement a service but an asp page. But has been refused...
    Friday, January 04, 2008 8:29 AM
  • I'm sorry to hear that.

     

    Please try asking this question in the WCF forum at http://forums.microsoft.com/MSDN/ShowForum.aspx?ForumID=118&SiteID=1.  Someone there will likely have a better idea of what this error message means. The terms in the error message are specific to WCF and I have little idea what they might mean.

    Friday, January 04, 2008 12:27 PM
    Moderator