Hello, I am trying to find a solution to my perplexing Java web service issue. I have probably spent few days, search forums and Google, but haven�t found anything relevant. In addition, this is my first Web service. Therefore all you pros about there please �please� please be easy with the terminology.
First my development environment: IDE: Eclipse JBOSS edition version 2/ Build: 2.0.0 Beta 2 Application Server: Tomcat v5.5 Web Service Run time: Apache Axis 1.3 JRE: Java 1.4 Web Standard Tool: v1.5
Problem: When I test my Web Service using the Eclipse web Service Explorer, the issue I am facing is with custom Web Service accepting more than one parameter. For example, if I enter non-null values, and when I test my WS using the Explorer on the console I can see that the second parameter�s value always is null (when I explicitly specified a non-null value). And if there are 3,4,5,6,7� input parameters and if I enter non-null value for each, leaving the first one all get passed as null to the WS during run time.
This is getting very frustrating and I am losing my confidence with Java. However, I feel there is some setting I am probably over looking. The SOAP envelopes will provide insight as to what I am facing.
I don�t know why this happening, but my guess is its something to do with tomcat�s http max length and I have tried looking for this but couldn�t find anything relevant either.
Any help would be appreciated.
Below is how my sample class looks. Also, I was invoking the setLatestStockData method from Eclipse WS explorer.
Originally posted by Rohit David: Problem: When I test my Web Service using the Eclipse web Service Explorer, the issue I am facing is with custom Web Service accepting more than one parameter. For example, if I enter non-null values, and when I test my WS using the Explorer on the console I can see that the second parameter�s value always is null (when I explicitly specified a non-null value). And if there are 3,4,5,6,7� input parameters and if I enter non-null value for each, leaving the first one all get passed as null to the WS during run time.
I suspect this happens because the WSDL is invalid. On the one hand it uses a document literal binding:
However with document literal binding only one root element is allowed in the message. Yet your request message has two elements:
So the first element is taken as the document while the others are ignored. You may want to look into the wrapped document/literal convention.
On an unrelated note: setLatestStockData has a void return type. Yet for some reason the equivalent web service method is mapped with a In-Out (request-response) message exchange pattern (MEP):
using a an empty (!!!) response message:
In fact it should simply be using the In-Only (one-way) MEP
which doesn't require a response messsage.
Another unrelated note:
Do not throw runtime exceptions in a web service method! That exception is clearly an application exception - therefore it should be a checked exception. As an application exception it needs to be mapped to a SOAP fault which is included in the WSDL and is part of the operation's binding:
Given that you seem to be stuck using Axis 1.x anyway I'd recommend that you'll leave your current development environment behind (too many moving parts, too easily derailed by the smallest problem) and move to something much more basic as described in Creating Web Services with Apache Axis until you have ironed out all the issues with your web service interface implementation (keep using tcpmon though).
This topic may also be of interest. [ February 19, 2008: Message edited by: Peer Reynders ]
You are allowed to have only one element under the <SOAP:BODY> element of your soap message and which should be defined by your schema. Please put the price and volume elements into the single element and try.
Thanks and Regards,<br />Senthil
Joined: Aug 19, 2005
Originally posted by Senthilkumar Adaickalam: You are allowed to have only one element under the <SOAP:BODY>
Ultimately this isn't a restriction imposed by SOAP or WSDL but a consequence of the various clarifications provided by the WS-I Basic Profile 1.0.
It makes sense that only a single element is allowed if the payload is an XML document which has to have a single root element. However as the SOAP message is an XML document itself it could be argued that the payload could simply be an XML fragment. In practice this caused nothing but problems leading to the rule of thumb that there should only be one single direct child element under the SOAP body element.