Granny's Programming Pearls
"inside of every large program is a small program struggling to get out"
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Will this plan work? What did I do wrong? Thanks.  RSS feed

Pengju Cheng
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi All,
I'm totally new to web services and I'm stuck with a urgent development task and hope to get help.

This is a piece of code that will be running on the application server side, there will be hundreds of devices each has its own IP address, but runs exactly the same web services, and my code will need to talk to each of the selected ones using its IP address. I see that in some cases the generated proxy class contain the particular IP of the device where the web service is running on. If this is the case all the time, then it won't be possible for me to use a client proxy class to talk to all the devices?

I'm currently trying something like this that will allow the code to use an IP 'dynamically':

URL url = new URL("");
QName serviceName = new QName("urn:Genus", "genusService");
Service service = Service.create(url, serviceName);
//These are for testing purpose
System.out.println ("List of QNames of service endpoints:");
Iterator it = service.getPorts();
while (it.hasNext ()) {
System.out.println (" " +;

I can see the single service named 'genusPortType' in the output, however when the following code is reached:

QName portName = new QName("urn:Genus", "genusPortType");
Dispatch<SOAPMessage> dispatch = service.createDispatch(portName, SOAPMessage.class,Service.Mode.MESSAGE);

I got an error ' Illegal argument combination [type=javax.xml.soap.SOAPMessage,mode=MESSAGE]'. I'm confused because I see the same usage in lots of sample codes. Is it because the 'portName' part decides that these two parameters are not fit based upon the definition of 'genusPortType'? If the operation is defined like this in the wsdl file, wht values should I use?

(I have to put an extra space between ':' and 'o' to make it not shown as a '')

<wsdl:binding name="genusBinding" type="cmi:genusPortType">
<wsdlsoap:binding style="rpc" transport="" />
<!-- login operation -->
<wsdl: operation name="login" >
<wsdlsoap: operation soapAction="" />
<wsdl:input name="loginRequest" >
<wsdlsoap:body encodingStyle="" use="encoded" />
<wsdl: output name="loginResponse" >
<wsdlsoap:body encodingStyle="" use="encoded" />
</wsdl: output>
</wsdl: operation>
Ivan Krizsan
Ranch Hand
Posts: 2198
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I suspect the best way is for the clients to include their IP as a parameter when sending requests to the web service.
In the web service, you will never be able to retrieve anything more than the IP of the last proxy the request passed through (this information can be obtained in a web service handler, from the servlet request object retrieved from the SOAP message context by using the key MessageContext.SERVLET_REQUEST).
This is not a problem if you can ensure that clients never go through any intermediaries when connecting to your web service, but if there are intermediaries, such as proxies, then there will be problems.
Best wishes!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!