0

I'm trying isolate a problem I'm having making an XML RPC call:

XDocument doc = new XDocument();
doc.Add(new XElement("methodCall",
        new XElement("methodName", "send"),
        new XElement("params",
            new XElement("param", new XElement("value", new XElement("string", this.ApiKey))),
            new XElement("param", new XElement("value", new XElement("string", this.FromAddress))),
            new XElement("param", new XElement("value", new XElement("string", recipient))),
            new XElement("param", new XElement("value", new XElement("string", contents)))  
        )
    )
);

HttpWebRequest req = (HttpWebRequest)WebRequest.Create("http://urlremoved");
req.ContentType = "text/xml";
req.Method = "POST";

XmlTextWriter writer = new XmlTextWriter(req.GetRequestStream(), Encoding.UTF8);
doc.Save(writer);

HttpWebResponse response = (HttpWebResponse)req.GetResponse();
StreamReader reader = new StreamReader(response.GetResponseStream());
return reader.ReadToEnd();

This just stalls and never times out (even if I set timeouts on req.TimeOut and req.ReadWriteTimeout). I removed the url, mostly to keep the focus on just the code.

Is there anything wrong with the code that would prevent this call from being made?

2 Answers 2

0

What happens if you call writer.Flush(); after you save the XML?

I'm not sure why this doesn't time out, but maybe it doesn't time out as no request is being made due to the fact that writing is buffered?

0

I ended up using http://www.xml-rpc.net/ instead of writing my own.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.