File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Web Services and the fly likes Will this plan work? What did I do wrong? Thanks. Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Web Services
Bookmark "Will this plan work? What did I do wrong? Thanks." Watch "Will this plan work? What did I do wrong? Thanks." New topic
Author

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

Pengju Cheng
Greenhorn

Joined: Dec 30, 2009
Posts: 2
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("http://172.21.159.52:80/cmi?wsdl");
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 (" " + it.next());


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 'javax.xml.ws.WebServiceException: 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="http://schemas.xmlsoap.org/soap/http" />
<!-- login operation -->
<wsdl: operation name="login" >
<wsdlsoap: operation soapAction="com.controlmod.terminal.services.web.services.Login#Login" />
<wsdl:input name="loginRequest" >
<wsdlsoap:body encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" use="encoded" />
</wsdl:input>
<wsdl: output name="loginResponse" >
<wsdlsoap:body encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" use="encoded" />
</wsdl: output>
</wsdl: operation>
.............
Ivan Krizsan
Ranch Hand

Joined: Oct 04, 2006
Posts: 2198
    
    1
Hi!
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!
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Will this plan work? What did I do wrong? Thanks.
 
Similar Threads
Optional operation parameters (long types)
Web service handler could not registered/called in client web service
Consuming a web service using Java
Problem with Java Client
DataHandler error in WSDL