I have tried to expand the 4-step tutorial by making the increase-price into a web-service. I have used the JPetStore as basis for figuring out what to do.
I have created a inteface :
and a remote one :Code:package server; import bus.Product; public interface ProductManagerService { public void increasePrice(int pct) ; public Product getProduct(int id); }
I have implemented the first interface into Product manager :Code:package server; import bus.Product; import java.rmi.Remote; import java.rmi.RemoteException; public interface RemoteProductManager extends Remote { public void increasePrice(int pct) throws RemoteException; }
Created the class reffered to in axis :Code:public class ProductManager implements Serializable,ProductManagerService {
I also added the axisi-servlet to the web.xml (same way as in JPetStore).Code:package server; import org.springframework.remoting.jaxrpc.ServletEndpointSupport; import bus.ProductManager; public class JaxRpcProductManager extends ServletEndpointSupport implements RemoteProductManager, ProductManagerService { private ProductManagerService prodman; protected void onInit() { System.out.println("Initiating ProductManager for RPC"); this.prodman = (ProductManagerService) getWebApplicationContext().getBean("prodMan"); } public void increasePrice(int pct) { System.out.println("Increasing price"); prodman.increasePrice(pct); } }
I created the server-config.wsdd and added this :
The bean-mapping for product was added as an next-step expansion to a method : getProductCode:<service name="ProductManager" provider="java:RPC"> <parameter name="allowedMethods" value="*"/> <parameter name="className" value="server.JaxRpcProductManager"/> <beanMapping qname="springtut:Product" xmlns:springtut="urn:springtut" languageSpecificType="java:bus.Product"/> </service>
and for verifying that the autogenerated wsdl-file looks good.
All of this makes the axis work fine, The servlet generates the correct responeses for all web-requests I make :
/springapp/axis
/springapp/axis/ProductManager
/springapp/axis/ProductManager?wsdl
Nothing wrong so far...
Until I try to access the service....
I test it using the DynamicInvoker-sample from the latest axis-distro (this is a nice utility for testing WebServices..)
I get a response like this :
I get the same message in the server-logs.Code:C:\development\axis-1_2RC1>java samples.client.DynamicInvoker http://localhost:8080/springapp/axis/ProductManager?wsdl increasePrice 10 Reading WSDL document from 'http://localhost:8080/springapp/axis/ProductManager?wsdl' Preparing Axis dynamic invocation Executing operation increasePrice with parameters: pct=10 Exception in thread "main" AxisFault faultCode: {http://schemas.xmlsoap.org/soap/envelope/}Server.userException faultSubcode: faultString: java.lang.IllegalStateException: No WebApplicationContext found: no ContextLoaderListener registered? faultActor: faultNode: faultDetail: {http://xml.apache.org/axis/}stackTrace:java.lang.IllegalStateException: No WebApplicationContext found: no ContextLoaderListener registered? at org.apache.axis.message.SOAPFaultBuilder.createFault(SOAPFaultBuilder.java:221) at org.apache.axis.message.SOAPFaultBuilder.endElement(SOAPFaultBuilder.java:128) at org.apache.axis.encoding.DeserializationContext.endElement(DeserializationContext.java:1077) at org.apache.xerces.parsers.SAXParser.endElement(SAXParser.java:1403) at org.apache.xerces.validators.common.XMLValidator.callEndElement(XMLValidator.java:1550) at org.apache.xerces.framework.XMLDocumentScanner$ContentDispatcher.dispatch(XMLDocumentScanner.java:1149) at org.apache.xerces.framework.XMLDocumentScanner.parseSome(XMLDocumentScanner.java:381) at org.apache.xerces.framework.XMLParser.parse(XMLParser.java:1098) at javax.xml.parsers.SAXParser.parse(Unknown Source) at org.apache.axis.encoding.DeserializationContext.parse(DeserializationContext.java:225) at org.apache.axis.SOAPPart.getAsSOAPEnvelope(SOAPPart.java:645) at org.apache.axis.Message.getSOAPEnvelope(Message.java:424) at org.apache.axis.handlers.soap.MustUnderstandChecker.invoke(MustUnderstandChecker.java:62) at org.apache.axis.client.AxisClient.invoke(AxisClient.java:173) at org.apache.axis.client.Call.invokeEngine(Call.java:2737) at org.apache.axis.client.Call.invoke(Call.java:2720) at org.apache.axis.client.Call.invoke(Call.java:2396) at org.apache.axis.client.Call.invoke(Call.java:2319) at org.apache.axis.client.Call.invoke(Call.java:1776) at samples.client.DynamicInvoker.invokeMethod(DynamicInvoker.java:237) at samples.client.DynamicInvoker.main(DynamicInvoker.java:114) {http://xml.apache.org/axis/}hostname:fh_lt java.lang.IllegalStateException: No WebApplicationContext found: no ContextLoaderListener registered? at org.apache.axis.message.SOAPFaultBuilder.createFault(SOAPFaultBuilder.java:221) at org.apache.axis.message.SOAPFaultBuilder.endElement(SOAPFaultBuilder.java:128) at org.apache.axis.encoding.DeserializationContext.endElement(DeserializationContext.java:1077) at org.apache.xerces.parsers.SAXParser.endElement(SAXParser.java:1403) at org.apache.xerces.validators.common.XMLValidator.callEndElement(XMLValidator.java:1550) at org.apache.xerces.framework.XMLDocumentScanner$ContentDispatcher.dispatch(XMLDocumentScanner.java:1149) at org.apache.xerces.framework.XMLDocumentScanner.parseSome(XMLDocumentScanner.java:381) at org.apache.xerces.framework.XMLParser.parse(XMLParser.java:1098) at javax.xml.parsers.SAXParser.parse(Unknown Source) at org.apache.axis.encoding.DeserializationContext.parse(DeserializationContext.java:225) at org.apache.axis.SOAPPart.getAsSOAPEnvelope(SOAPPart.java:645) at org.apache.axis.Message.getSOAPEnvelope(Message.java:424) at org.apache.axis.handlers.soap.MustUnderstandChecker.invoke(MustUnderstandChecker.java:62) at org.apache.axis.client.AxisClient.invoke(AxisClient.java:173) at org.apache.axis.client.Call.invokeEngine(Call.java:2737) at org.apache.axis.client.Call.invoke(Call.java:2720) at org.apache.axis.client.Call.invoke(Call.java:2396) at org.apache.axis.client.Call.invoke(Call.java:2319) at org.apache.axis.client.Call.invoke(Call.java:1776) at samples.client.DynamicInvoker.invokeMethod(DynamicInvoker.java:237) at samples.client.DynamicInvoker.main(DynamicInvoker.java:114)
Also make note that the line "Initiating ProductManager.." never shows up in any log, as it does when I add the same line in JPetStore.
So now my question is : What am I missing ??


Reply With Quote
