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,
Tracey
======================
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
- public String createDiary(final String library,
- final BigDecimal companyCode, final Date diaryDate, final Date actionedDate,
- final String diaryMessage) throws RemoteException
Expand|Select|Wrap|Line Numbers
- public DiarySoapBean getDiary(final String library,
- 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
- <soapenv:Body xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
- <ns1:createDiary soapenc:root="1" xmlns:ns1="http://localhost:8080/morph_zta/services/DiaryService" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/">
- <library xsi:type="xsd:string" xmlns:xsi="http://www.w3.org/1999/XMLSchema-instance">ZRMORPHTA</library>
- <companyCode xsi:type="xsd:Decimal" xmlns:xsi="http://www.w3.org/1999/XMLSchema-instance">1</companyCode>
- <diaryDate xsi:type="xsd:date" xmlns:xsi="http://www.w3.org/1999/XMLSchema-instance">2007-01-01Z</diaryDate>
- <actionedDate xsi:type="xsd:date" xmlns:xsi="http://www.w3.org/1999/XMLSchema-instance">2007-01-01Z</actionedDate>
- <diaryMessage xsi:type="xsd:string" xmlns:xsi="http://www.w3.org/1999/XMLSchema-instance"/>Blah blah blah</diaryMessage>
- </ns1:createDiary>
- </soapenv:Body>
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
- <listener>
- <listener-class>
- org.apache.axis.transport.http.AxisHTTPSessionListener
- </listener-class>
- </listener>
- <servlet>
- <display-name>Apache-Axis Servlet</display-name>
- <servlet-name>axis</servlet-name>
- <servlet-class>
- com.workingmouse.webservice.axis.SpringAxisServlet
- </servlet-class>
- </servlet>
- <servlet-mapping>
- <servlet-name>axis</servlet-name>
- <url-pattern>/servlet/AxisServlet</url-pattern>
- </servlet-mapping>
- <servlet-mapping>
- <servlet-name>axis</servlet-name>
- <url-pattern>*.jws</url-pattern>
- </servlet-mapping>
- <servlet-mapping>
- <servlet-name>axis</servlet-name>
- <url-pattern>/services/*</url-pattern>
- </servlet-mapping>
Expand|Select|Wrap|Line Numbers
- <!-- Global config options -->
- <globalConfiguration>
- <parameter name="adminPassword" value="admin"/>
- <parameter name="attachments.Directory" value="./attachments"/>
- <parameter name="attachments.implementation"
- value="org.apache.axis.attachments.AttachmentsImpl"/>
- <parameter name="sendXsiTypes" value="true"/>
- <parameter name="sendMultiRefs" value="true"/>
- <parameter name="sendXMLDeclaration" value="true"/>
- <parameter name="axis.sendMinimizedElements" value="true"/>
- <requestFlow>
- <handler type="java:org.apache.axis.handlers.JWSHandler">
- <parameter name="scope" value="session"/>
- </handler>
- <handler type="java:org.apache.axis.handlers.JWSHandler">
- <parameter name="scope" value="request"/>
- <parameter name="extension" value=".jwr"/>
- </handler>
- <handler name="acegiAuthenticationHandler" type="java:{our}.AcegiAuthenticationHandler"/>
- </requestFlow>
- <responseFlow>
- <handler name="OutgoingSOAPMessageViewer" type="java:{our}.OutgoingSOAPMessageViewer"/>
- </responseFlow>
- </globalConfiguration>
- <!-- Handlers -->
- <handler name="LocalResponder"
- type="java:org.apache.axis.transport.local.LocalResponder"/>
- <handler name="URLMapper"
- type="java:org.apache.axis.handlers.http.URLMapper"/>
- <handler name="Authenticate"
- type="java:org.apache.axis.handlers.SimpleAuthenticationHandler"/>
- <!-- Axis services -->
- <service name="AdminService" provider="java:MSG">
- <parameter name="allowedMethods" value="AdminService"/>
- <parameter name="enableRemoteAdmin" value="true"/>
- <parameter name="className" value="org.apache.axis.utils.Admin"/>
- <namespace>http://xml.apache.org/axis/wsdd/</namespace>
- </service>
- <service name="Version" provider="java:RPC">
- <parameter name="allowedMethods" value="getVersion"/>
- <parameter name="className" value="org.apache.axis.Version"/>
- </service>
- <!-- Global config options -->
- <transport name="http">
- <requestFlow>
- <handler type="URLMapper"/>
- <handler type="java:org.apache.axis.handlers.http.HTTPAuthHandler"/>
- </requestFlow>
- </transport>
- <transport name="local">
- <responseFlow>
- <handler type="LocalResponder"/>
- </responseFlow>
- </transport>
- <service name="DiaryServices" provider="Handler" style="rpc">
- <parameter name="handlerClass" value="com.workingmouse.webservice.axis.SpringBeanRPCProvider"/>
- <parameter name="springBean" value="diaryServices"/>
- <parameter name="springBeanClass" value="uk.co.trisystems.morph.ta.diary.soap.DiaryService"/>
- <parameter name="allowedMethods" value="createDiary getDiary"/>
- <parameter name="scope" value="application"/>
- <beanMapping qname="ns:diary" xmlns:ns="urn:DiaryService" languageSpecificType="java:uk.co.trisystems.morph.ta.diary.soap.DiarySoapBean"/>
- </service>
Cheers
Tracey Annison