Skip to Main Content

Java APIs

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

watch the http request a programm sends

843790Oct 28 2009 — edited Nov 8 2009
Hello

I want to write a SOAP-Request to a HttpURLConnection Object.
public static void main(String[] args) 
	{
		InputStream is;
		String[] mess = {"<?xml version=\"1.0\" encoding=\"utf-8\"?>",
				"<soap:Envelope xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" xmlns:soap=\"http://schemas.xmlsoap.org/soap/envelope/\">",
				"<soap:Body>",
				"<GetSlideData xmlns=\"http://tempuri.org/\" />",
				"</soap:Body>",
				"</soap:Envelope>"};

		try {
			URL url = new URL("http://localhost:4351/SlideService/Service.asmx?op=GetSlideData");
			HttpURLConnection urlcon = (HttpURLConnection)url.openConnection();
			
			urlcon.setRequestMethod("POST");
			urlcon.setDoOutput( true );
			urlcon.connect();
			OutputStream out = urlcon.getOutputStream();
			for(int i = 0; i < mess.length; i++)
			{
				for(int j = 0; j < mess.length(); j++)
out.write((int)mess[i].charAt(j));
}
out.close();
urlcon.toString();
is = urlcon.getInputStream();
System.out.println("ContentType: " + urlcon.getContentType());

}
catch (Exception e)
{

e.printStackTrace();
}
}
When I start this program i get a:

Server returned HTTP response code: 415 for URL: http://localhost:4351/SlideService/Service.asmx?op=GetSlideData

The request should look like this:
POST /SlideService/Service.asmx HTTP/1.1
Host: localhost
Content-Type: text/xml; charset=utf-8
Content-Length: length
SOAPAction: "http://tempuri.org/GetSlideData"

<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
<soap:Body>
<GetSlideData xmlns="http://tempuri.org/" />
</soap:Body>
</soap:Envelope>
I'm looking for a tool or a way to see the http request, that the application does send.
Does someone have an idea how to do this?

Kind regards,
ClaudeMichelle                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Dec 6 2009
Added on Oct 28 2009
18 comments
348 views