frodeh
Oct 12th, 2004, 02:46 AM
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 :
package server;
import bus.Product;
public interface ProductManagerService {
public void increasePrice(int pct) ;
public Product getProduct(int id);
}
and a remote one :
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;
}
I have implemented the first interface into Product manager :
public class ProductManager implements Serializable,ProductManagerService {
Created the class reffered to in axis :
package server;
import org.springframework.remoting.jaxrpc.ServletEndpoin tSupport;
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 also added the axisi-servlet to the web.xml (same way as in JPetStore).
I created the server-config.wsdd and added this :
<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>
The bean-mapping for product was added as an next-step expansion to a method : getProduct
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 :
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.createFau lt(SOAPFaultBuilder.java:221)
at org.apache.axis.message.SOAPFaultBuilder.endElemen t(SOAPFaultBuilder.java:128)
at org.apache.axis.encoding.DeserializationContext.en dElement(DeserializationContext.java:1077)
at org.apache.xerces.parsers.SAXParser.endElement(SAX Parser.java:1403)
at org.apache.xerces.validators.common.XMLValidator.c allEndElement(XMLValidator.java:1550)
at org.apache.xerces.framework.XMLDocumentScanner$Con tentDispatcher.dispatch(XMLDocumentScanner.java:11 49)
at org.apache.xerces.framework.XMLDocumentScanner.par seSome(XMLDocumentScanner.java:381)
at org.apache.xerces.framework.XMLParser.parse(XMLPar ser.java:1098)
at javax.xml.parsers.SAXParser.parse(Unknown Source)
at org.apache.axis.encoding.DeserializationContext.pa rse(DeserializationContext.java:225)
at org.apache.axis.SOAPPart.getAsSOAPEnvelope(SOAPPar t.java:645)
at org.apache.axis.Message.getSOAPEnvelope(Message.ja va:424)
at org.apache.axis.handlers.soap.MustUnderstandChecke r.invoke(MustUnderstandChecker.java:62)
at org.apache.axis.client.AxisClient.invoke(AxisClien t.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(Dynamic Invoker.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.createFau lt(SOAPFaultBuilder.java:221)
at org.apache.axis.message.SOAPFaultBuilder.endElemen t(SOAPFaultBuilder.java:128)
at org.apache.axis.encoding.DeserializationContext.en dElement(DeserializationContext.java:1077)
at org.apache.xerces.parsers.SAXParser.endElement(SAX Parser.java:1403)
at org.apache.xerces.validators.common.XMLValidator.c allEndElement(XMLValidator.java:1550)
at org.apache.xerces.framework.XMLDocumentScanner$Con tentDispatcher.dispatch(XMLDocumentScanner.java:11 49)
at org.apache.xerces.framework.XMLDocumentScanner.par seSome(XMLDocumentScanner.java:381)
at org.apache.xerces.framework.XMLParser.parse(XMLPar ser.java:1098)
at javax.xml.parsers.SAXParser.parse(Unknown Source)
at org.apache.axis.encoding.DeserializationContext.pa rse(DeserializationContext.java:225)
at org.apache.axis.SOAPPart.getAsSOAPEnvelope(SOAPPar t.java:645)
at org.apache.axis.Message.getSOAPEnvelope(Message.ja va:424)
at org.apache.axis.handlers.soap.MustUnderstandChecke r.invoke(MustUnderstandChecker.java:62)
at org.apache.axis.client.AxisClient.invoke(AxisClien t.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(Dynamic Invoker.java:237)
at samples.client.DynamicInvoker.main(DynamicInvoker. java:114)
I get the same message in the server-logs.
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 ??
I have created a inteface :
package server;
import bus.Product;
public interface ProductManagerService {
public void increasePrice(int pct) ;
public Product getProduct(int id);
}
and a remote one :
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;
}
I have implemented the first interface into Product manager :
public class ProductManager implements Serializable,ProductManagerService {
Created the class reffered to in axis :
package server;
import org.springframework.remoting.jaxrpc.ServletEndpoin tSupport;
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 also added the axisi-servlet to the web.xml (same way as in JPetStore).
I created the server-config.wsdd and added this :
<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>
The bean-mapping for product was added as an next-step expansion to a method : getProduct
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 :
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.createFau lt(SOAPFaultBuilder.java:221)
at org.apache.axis.message.SOAPFaultBuilder.endElemen t(SOAPFaultBuilder.java:128)
at org.apache.axis.encoding.DeserializationContext.en dElement(DeserializationContext.java:1077)
at org.apache.xerces.parsers.SAXParser.endElement(SAX Parser.java:1403)
at org.apache.xerces.validators.common.XMLValidator.c allEndElement(XMLValidator.java:1550)
at org.apache.xerces.framework.XMLDocumentScanner$Con tentDispatcher.dispatch(XMLDocumentScanner.java:11 49)
at org.apache.xerces.framework.XMLDocumentScanner.par seSome(XMLDocumentScanner.java:381)
at org.apache.xerces.framework.XMLParser.parse(XMLPar ser.java:1098)
at javax.xml.parsers.SAXParser.parse(Unknown Source)
at org.apache.axis.encoding.DeserializationContext.pa rse(DeserializationContext.java:225)
at org.apache.axis.SOAPPart.getAsSOAPEnvelope(SOAPPar t.java:645)
at org.apache.axis.Message.getSOAPEnvelope(Message.ja va:424)
at org.apache.axis.handlers.soap.MustUnderstandChecke r.invoke(MustUnderstandChecker.java:62)
at org.apache.axis.client.AxisClient.invoke(AxisClien t.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(Dynamic Invoker.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.createFau lt(SOAPFaultBuilder.java:221)
at org.apache.axis.message.SOAPFaultBuilder.endElemen t(SOAPFaultBuilder.java:128)
at org.apache.axis.encoding.DeserializationContext.en dElement(DeserializationContext.java:1077)
at org.apache.xerces.parsers.SAXParser.endElement(SAX Parser.java:1403)
at org.apache.xerces.validators.common.XMLValidator.c allEndElement(XMLValidator.java:1550)
at org.apache.xerces.framework.XMLDocumentScanner$Con tentDispatcher.dispatch(XMLDocumentScanner.java:11 49)
at org.apache.xerces.framework.XMLDocumentScanner.par seSome(XMLDocumentScanner.java:381)
at org.apache.xerces.framework.XMLParser.parse(XMLPar ser.java:1098)
at javax.xml.parsers.SAXParser.parse(Unknown Source)
at org.apache.axis.encoding.DeserializationContext.pa rse(DeserializationContext.java:225)
at org.apache.axis.SOAPPart.getAsSOAPEnvelope(SOAPPar t.java:645)
at org.apache.axis.Message.getSOAPEnvelope(Message.ja va:424)
at org.apache.axis.handlers.soap.MustUnderstandChecke r.invoke(MustUnderstandChecker.java:62)
at org.apache.axis.client.AxisClient.invoke(AxisClien t.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(Dynamic Invoker.java:237)
at samples.client.DynamicInvoker.main(DynamicInvoker. java:114)
I get the same message in the server-logs.
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 ??