The Servlet writes the XML file to disk from the POSTed string data it gets.
I've noticed that running the .NET "EXE" doesn't always result in an XML file being created, though most of the time, it does work.
For those times, often the first time I run it, the Tomcat error log says that the Servlet has an IO Exception and with:
Not sure what's causing this.
The .NET class is simple and similar to this:
// Create a request using a URL that can receive a post.
WebRequest request = WebRequest.Create ("http://myServletAddressHere");
// Set the Method property of the request to POST.
request.Method = "POST";
// Create POST data and convert it to a byte array.
string postData = // call to .NET Web Service goes here to get XML String
byte byteArray = Encoding.UTF8.GetBytes (postData);
// Set the ContentType property of the WebRequest.
request.ContentType = "application/x-www-form-urlencoded";
// Set the ContentLength property of the WebRequest.
request.ContentLength = byteArray.Length;
// Get the request stream.
Stream dataStream = request.GetRequestStream ();
// Write the data to the request stream.
dataStream.Write (byteArray, 0, byteArray.Length);
// Close the Stream object.
Michael Angstadt wrote:Why are you setting the content type to "application/x-www-form-urlencoded"? If you're sending XML, shouldn't it be "text/xml"?
Maybe the .NET web service you are using to get the XML is returning an empty response? Maybe this would cause problems?
In any case, I got the Java version of the client working and there are zero problems now.
Turned out that the "Service" class that .NET generated had, in the comments, instructions how to call the .NET WS. That was a nice touch.
Thanks for your reply.