Tuesday, July 29, 2008

Ways to send an input to webmethods

There are several ways to send an input to webmethods:

  1. Using Get method. Giving the input service's name like the variable name. To note that the character is in case sensitive.
  2. Using Post method. This is pretty much same like the above. The different must be the hidden data posted in this method.
For more information is in the webmethod's documentation page 356.

The URL address to invoke webmethod's service is in the following formats:

http://:5555/invoke/folder/serviceName?variableA=valueA&variableB=valueB

I created a code to post a variable using HttpClient (developed by Apache). The following is a piece of code that I created:

client.getState().setCredentials(new AuthScope("localhost", 5555), new
UsernamePasswordCredentials("Administrator","manage"));
PostMethod postMethod = new PostMethod(url);
postMethod.addParameter("name", "nama saya arie murdianto ganteng banged");
postMethod.addParameter("USERNAME", "Administrator");
postMethod.addParameter("PASSWORD", "manage");
postMethod.setDoAuthentication(true);

.....
byte[] responseBody = postMethod.getResponseBody();

My flow step is only performing the length of the input String. For your information that the latest HttpClient is having 2 dependencies. They are commons codec and commons logging

No comments: