You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-user@axis.apache.org by Robert Olivier <rj...@me.com> on 2009/04/17 22:27:47 UTC

programmatic service configuration problem

I have an existing application using embedded jetty, that configures  
servlets manually rather than through services.xml.  Using Axis2  
1.4.1,  I have generated code using wsdl2code and configured my  
service per some posts that I saw on this topic.  My servlet looks  
like this:

public class ParlayAxisServlet extends AxisServlet {

    final private Logger logger =  
LoggerFactory.getLogger(this.getClass());
    private String serviceName;

    public ParlayAxisServlet(String serviceName) {
      this.serviceName = serviceName;
    }

    public void init(ServletConfig config) throws ServletException
    {
      super.init(config);

      logger.debug("initializing parlay axis servlet");
      AxisService service;
      try {
        service =  
AxisService.createService(serviceName,axisConfiguration);
        axisConfiguration.addService(service);
        axisConfiguration.startService(service.getName());
        logger.debug("parlay axis servlet initialized for service  
name: " + service.getName());
      } catch (AxisFault e) {
        throw new ServletException("unable to init servlet", e);
      }
    }
}

I am testing this using Altova XMLSpy 2009 Enterprise, using its SOAP  
features.  I open the original WSDL that the code was generated from,  
and execute an operation.  The server gets the request and routes it  
to the service operation as expected.  The service implementation  
looks like:

public class TerminalLocationService implements  
TerminalLocationServiceSkeletonInterface {

    /**
    * Auto generated method signature
    *
    * @param getLocation2
    * @throws PolicyException :
    * @throws ServiceException :
    */

    public  GetLocationResponseE getLocation (GetLocationE  
getLocation2) throws PolicyException,ServiceException {

        GetLocation requestObject = getLocation2.getGetLocation();
        if(requestObject == null)    throw new  
ServiceException("request object is null");
        org.apache.axis2.databinding.types.URI addressURI =  
requestObject.getAddress();
        if(addressURI == null)        throw new  
ServiceException("address URI is null");

	throw new ServiceException("got to the bottom of the operation  
implementation");
  }
}

When it gets here, the request object is null, as if axis did not  
parse the request XML being sent.  In order to try and debug this, I  
put some logging into the generated  
TerminalLocationServiceMessageReceiverInOut.java   and discovered that  
invokeBusinessLogic() is never being called.  Then upon closer  
inspection of my logs I see:

org.apache.axis2.AxisFault: request object is null
	at  
org 
.apache 
.axis2 
.rpc 
.receivers 
.RPCMessageReceiver.invokeBusinessLogic(RPCMessageReceiver.java:158)
	at  
org 
.apache 
.axis2 
.receivers 
.AbstractInOutMessageReceiver 
.invokeBusinessLogic(AbstractInOutMessageReceiver.java:40)
	at  
org 
.apache 
.axis2 
.receivers 
.AbstractMessageReceiver.receive(AbstractMessageReceiver.java:100)
	at org.apache.axis2.engine.AxisEngine.receive(AxisEngine.java:176)
	at  
org 
.apache 
.axis2 
.transport 
.http 
.HTTPTransportUtils.processHTTPPostRequest(HTTPTransportUtils.java:275)
	at  
org.apache.axis2.transport.http.AxisServlet.doPost(AxisServlet.java:133)
	at javax.servlet.http.HttpServlet.service(HttpServlet.java:760)
	at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
	at org.mortbay.jetty.servlet.ServletHolder.handle(ServletHolder.java: 
502)


So the generated receiver is never being called.  Is there something  
special I have to do to make axis use this receiver rather than the  
AbstractMessageReceiver that I now see in my log output?

Thanks in advance!

Robert Olivier

Re: programmatic service configuration problem

Posted by Robert Olivier <rj...@me.com>.
Sagara,

I started reading the axis source yesterday and discovered this at  
about 10 o'clock last night!  Thanks so much for the reply!

robert

On Apr 18, 2009, at 10:56 AM, Sagara Gunathunga wrote:

> Hi Robert,
>
>>     AxisService service;
>>     try {
>>       service =  
>> AxisService.createService(serviceName,axisConfiguration);
>
> You cant use above createService(...) method with a custom
> MessageReceiver , it's only work with RPCMessageReceiver and
> RPCInOnlyMessageReceiver. There are another two  createService(...)
> methods on org.apache.axis2.description.AxisService class , you could
> try for one of them.
>
> In both methods it is required to pass custom MessageReceivers
> explicitly as a Map and you could create a Map instance with relevant
> MEPs as follows ,
>
> Map messageReceiverClassMap = new HashMap();
> messageReceiverClassMap.put("http://www.w3.org/ns/wsdl/in-out",
> 					TerminalLocationServiceMessageReceiverInOut.class.newInstance());
>
> Hope this will help you.
>
> Thanks,
>
> -- 
> Sagara Gunathunga
>
> Blog - http://ssagara.blogspot.com
> Web - http://sagaras.awardspace.com/


Re: programmatic service configuration problem

Posted by Sagara Gunathunga <sa...@gmail.com>.
Hi Robert,

>     AxisService service;
>     try {
>       service = AxisService.createService(serviceName,axisConfiguration);

You cant use above createService(...) method with a custom
MessageReceiver , it's only work with RPCMessageReceiver and
RPCInOnlyMessageReceiver. There are another two  createService(...)
methods on org.apache.axis2.description.AxisService class , you could
try for one of them.

In both methods it is required to pass custom MessageReceivers
explicitly as a Map and you could create a Map instance with relevant
MEPs as follows ,

Map messageReceiverClassMap = new HashMap();
messageReceiverClassMap.put("http://www.w3.org/ns/wsdl/in-out",
					TerminalLocationServiceMessageReceiverInOut.class.newInstance());

Hope this will help you.

Thanks,

-- 
Sagara Gunathunga

Blog - http://ssagara.blogspot.com
Web - http://sagaras.awardspace.com/