By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
449,188 Members | 1,307 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 449,188 IT Pros & Developers. It's quick & easy.

Behaviour of AXIS (with Spring and Java) in response to bad webservice calls

P: 4
I wonder if you can help me - I'm new to this, and working in a project that has already been configured to work with Axis.

We have a Java project built with the Spring framework, in order to provide webservices for access via SOAP. As I understand it (ie not very well!) Axis works to accept these SOAP messages from the client and transform them into calls on our Java methods, and do the reverse with the responses - cool! Which is excellent, and it works well with the config files we have already set up.

But I have two problems/questions, which may well be related…

2) In trying to test what exactly happens in which case, I sent some test messages to the service, and found that I could send incorrect parameter names, and sometimes the service still gets called! Axis seems to match the data it recieves to the parameters of the method in some clever way that I don’t understand. Sometimes this works, sometimes it shows a type error. But it seems to depend what parameter I rename as to what exactly happens, so the results are (superficially, at least) unpredictable! I'm sure this behaviour is configurable in some way, but I can't seem to find out how this is done. I'd like to make it so that missing parameters are passed into the method as nulls (as is happening now), but that badly named, duplicated or extraneous parameters are refused, with a specific errormessage stating what the issue is. Similarly, I'd like to reply with an explanatory message if a parameter is passed wth an incorrect type, rather than just a message "org.xml.sax.SAXException: Bad types" that does not detail which parameter is problematic.

1) The client can receive a "500" response, with an "Internal Server Error" message, although I'm having trouble figuring out exactly when this happens. I'd like to be able to configure what message they receive, in order to give them more information about what they got wrong.

I just don't know where to start with this - I'm sure there must be ways of configuring all this!

As much info about an example of what I'm looking at as seems sensible follows. Please forgive me if I've used incorrect terminology somewhere! :)

Thanks a heap,


So, let's say I have a Java class called DiaryService, with a method called createDiary that takes the appropriate data and returns a confirmation/error message - it starts like this :
Expand|Select|Wrap|Line Numbers
  1.     public String createDiary(final String library,
  2.             final BigDecimal companyCode, final Date diaryDate,  final Date actionedDate, 
  3.     final String diaryMessage) throws RemoteException 
And another called GetDiary that returns a Diary as a SOAP bean which looks like this :
Expand|Select|Wrap|Line Numbers
  1.     public DiarySoapBean getDiary(final String library,
  2.             final BigDecimal companyCode, final Date diaryDate) throws RemoteException

Axis very helpfully lets me access the createDiary and getDiary, by sending XML messages like this example:
Expand|Select|Wrap|Line Numbers
  1. <soapenv:Body xmlns:soapenv="">
  2. <ns1:createDiary soapenc:root="1" xmlns:ns1="http://localhost:8080/morph_zta/services/DiaryService" xmlns:soapenc="">
  3. <library xsi:type="xsd:string" xmlns:xsi="">ZRMORPHTA</library>
  4. <companyCode xsi:type="xsd:Decimal" xmlns:xsi="">1</companyCode>
  5. <diaryDate xsi:type="xsd:date" xmlns:xsi="">2007-01-01Z</diaryDate>
  6. <actionedDate xsi:type="xsd:date" xmlns:xsi="">2007-01-01Z</actionedDate>
  7. <diaryMessage xsi:type="xsd:string" xmlns:xsi=""/>Blah blah blah</diaryMessage>
  8. </ns1:createDiary>
  9. </soapenv:Body>
If I rename a parameter, the service may get called, with some other data in that parameter or not, or may not get called at all and the user get a "SAXException: Bad types" error message. I would like it to return a message stating that the parameter is not expected.
If I duplicate a parameter, the first occurrence appears to be used, and the next ignored. I would like it to return a message saying tnat the extra parameter is not expected.
If I add gibberish parameters, I get a "No such operation" message. I would like to be able to tell which parameters are incorrect.

We have entries like this in web.xml:
Expand|Select|Wrap|Line Numbers
  1.     <listener>
  2.         <listener-class>
  3.             org.apache.axis.transport.http.AxisHTTPSessionListener
  4.     </listener-class>
  5.     </listener>
  7.     <servlet>
  8.         <display-name>Apache-Axis Servlet</display-name>
  9.         <servlet-name>axis</servlet-name>
  10.         <servlet-class>
  11.             com.workingmouse.webservice.axis.SpringAxisServlet
  12.     </servlet-class>
  13.     </servlet>
  15.     <servlet-mapping>
  16.         <servlet-name>axis</servlet-name>
  17.         <url-pattern>/servlet/AxisServlet</url-pattern>
  18.     </servlet-mapping>
  20.     <servlet-mapping>
  21.         <servlet-name>axis</servlet-name>
  22.         <url-pattern>*.jws</url-pattern>
  23.     </servlet-mapping>
  25.     <servlet-mapping>
  26.         <servlet-name>axis</servlet-name>
  27.         <url-pattern>/services/*</url-pattern>
  28.     </servlet-mapping>
And these bits in our server-config.wsdd :
Expand|Select|Wrap|Line Numbers
  1.     <!-- Global config options -->
  2.     <globalConfiguration>
  3.         <parameter name="adminPassword" value="admin"/>
  4.         <parameter name="attachments.Directory" value="./attachments"/>
  5.         <parameter name="attachments.implementation"
  6.                 value="org.apache.axis.attachments.AttachmentsImpl"/>
  7.         <parameter name="sendXsiTypes" value="true"/>
  8.         <parameter name="sendMultiRefs" value="true"/>
  9.         <parameter name="sendXMLDeclaration" value="true"/>
  10.         <parameter name="axis.sendMinimizedElements" value="true"/>
  12.         <requestFlow>
  14.             <handler type="java:org.apache.axis.handlers.JWSHandler">
  15.                 <parameter name="scope" value="session"/>
  16.             </handler>
  17.             <handler type="java:org.apache.axis.handlers.JWSHandler">
  18.                 <parameter name="scope" value="request"/>
  19.                 <parameter name="extension" value=".jwr"/>
  20.             </handler>
  22.     <handler name="acegiAuthenticationHandler" type="java:{our}.AcegiAuthenticationHandler"/>
  23.         </requestFlow>
  25.     <responseFlow>
  26.         <handler name="OutgoingSOAPMessageViewer" type="java:{our}.OutgoingSOAPMessageViewer"/>
  27.     </responseFlow>
  28.     </globalConfiguration>
  30.     <!-- Handlers -->
  31.     <handler name="LocalResponder"
  32.             type="java:org.apache.axis.transport.local.LocalResponder"/>
  33.     <handler name="URLMapper"
  34.             type="java:org.apache.axis.handlers.http.URLMapper"/>
  35.     <handler name="Authenticate"
  36.             type="java:org.apache.axis.handlers.SimpleAuthenticationHandler"/>
  38.     <!-- Axis services -->
  39.     <service name="AdminService" provider="java:MSG">
  40.         <parameter name="allowedMethods" value="AdminService"/>
  41.         <parameter name="enableRemoteAdmin" value="true"/>
  42.         <parameter name="className" value="org.apache.axis.utils.Admin"/>
  43.         <namespace></namespace>
  44.     </service>
  45.     <service name="Version" provider="java:RPC">
  46.         <parameter name="allowedMethods" value="getVersion"/>
  47.         <parameter name="className" value="org.apache.axis.Version"/>
  48.     </service>
  50.     <!-- Global config options -->
  51.     <transport name="http">
  52.         <requestFlow>
  53.             <handler type="URLMapper"/>
  54.             <handler type="java:org.apache.axis.handlers.http.HTTPAuthHandler"/>
  55.         </requestFlow>
  56.     </transport>
  57.     <transport name="local">
  58.         <responseFlow>
  59.             <handler type="LocalResponder"/>
  60.         </responseFlow>
  61.     </transport>
  63.     <service name="DiaryServices" provider="Handler" style="rpc">
  64.         <parameter name="handlerClass" value="com.workingmouse.webservice.axis.SpringBeanRPCProvider"/>
  65.         <parameter name="springBean" value="diaryServices"/>
  66.         <parameter name="springBeanClass" value=""/>
  67.         <parameter name="allowedMethods" value="createDiary getDiary"/>
  68.         <parameter name="scope" value="application"/>
  69.         <beanMapping qname="ns:diary" xmlns:ns="urn:DiaryService" languageSpecificType=""/>
  70.     </service>

Tracey Annison
Jul 13 '07 #1
Share this question for a faster answer!
Share on Google+

Post your reply

Sign in to post your reply or Sign up for a free account.