How to access parameters when building web services?
This is my first time developing a web service with IDEA, so please be gentle.
I followed www.jetbrains.com/idea/docs/Web_Services_with_IntelliJ_IDEA.pdf
and created a hello world web service. I can access it in browser using http://localhost:8080/services/HelloWorld?method=sayHelloWorldFrom
Now then web service method sayHelloWorldFrom, takes a parameters "from"
public String sayHelloWorldFrom(String from) {
String result = "Hello, world, from " + from;
System.out.println(result);
return result;
}
How can I specify the value of from using the URL? I tried http://localhost:8080/services/HelloWorld?method=sayHelloWorldFrom&from=test and it generates an error message:
faultcode: soapenv:Server.userException
faultstring:org.xml.sax.SAXException: SimpleDeserializer encountered a child element, which is NOT expected, in something it was trying to deserialize.
Can you please assist me? thanks!
Sanders
Please sign in to leave a comment.
Can anyone please help?
Hello Frank!
This very helpful guide about Web Services http://java.sun.com/webservices/docs/2.0/tutorial/doc/
Why don't you:
1. Get WSDL from server that describes your WebService
2. Generate a client from that WSDL
3. Pass a parameter "from" into that client.
This very good example how to create such a client: http://java.sun.com/webservices/docs/2.0/tutorial/doc/JAXWS3.html#wp144801