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 Rishi krish <ri...@gmail.com> on 2007/05/16 22:22:07 UTC

service deployment using axis2 api

Hi
I was wondering if anyone tried programmatic deployment of Axis2 services
without say creating an aar file. I have Axis2 deployed as a web module
inside my application ear file. Its supposed to run on any app server. I am
trying to use the code below [which will be called at startup of the server]
to deploy a service in Axis2.

I am using the axis2 admin console to see if the service appears - but I
dont see it in the available services and if I try to send a message to it -
it returns with "service not found" error. I have the AxisServlet deployed
in my web.xml but I didnt set any axis2.xml.path or axis2.repository.path.
Not sure what else I need to do to get this working.

If try the aar way - the same service works great. Its only when I try to go
without aar I have this issue.

 public void deployWebService(String serviceName, String operation) throws
AxisFault
 {
        AxisServiceGroup serviceGroup;
   AxisConfiguration axis2Config;
   String axisConfigFile = "axis2.xml";
   ConfigurationContext configContext;
  System.out.println("In deployyyyyyyyyyyyyyyyyyyyyyyyyy");
  try
  {
   if (configContext == null)
   {
    configContext = ConfigurationContextFactory
     .createConfigurationContextFromFileSystem("C:\\deployment\\axis2",
"C:\\deployment\\axis2\\axis2.xml");
    axis2Config = configContext.getAxisConfiguration();
   }
  }
  catch (AxisFault e)
  {
   e.printStackTrace();
  }


  if (serviceGroup == null)
  {
   serviceGroup = new AxisServiceGroup();
  }
  AxisService axisService = new AxisService(serviceName);
  axisService.setClientSide(false);
  axisService.setParent(serviceGroup);

  AxisOperation axisOp = AxisOperationFactory.getAxisOperation(
WSDLConstants.MEP_CONSTANT_IN_OUT);
  axisOp.setName(new QName(operation));
  MessageReceiver messageReceiver = new RawXMLINOutMessageReceiver();
  axisOp.setMessageReceiver(messageReceiver);
  axisOp.setSoapAction("urn:"+operation);
  PhasesInfo pinfo = axis2Config.getPhasesInfo();
  pinfo.setOperationPhases(axisOp);
  axisService.addOperation(axisOp);

  Parameter param1 = new Parameter(WSConstants.PARAM_SERVICE_CLASS,
WSConstants.STANDARD_SERVICE);
  axisService.addParameter(param1);

  Parameter param2 = new Parameter(WSConstants.MAX_SERVICE, serviceName);
  axisService.addParameter(param2);

  Parameter param3 = new Parameter(WSConstants.PARAM_QUEUED, "false");
  axisService.addParameter(param3);

  Parameter param4 = new Parameter(WSConstants.PARAM_SECURITY, "None");
  axisService.addParameter(param4);

  serviceGroup.addService(axisService);

  axis2Config.addServiceGroup(serviceGroup);

 }


-- 
thanks
Rishi

Re: service deployment using axis2 api

Posted by Rishi krish <ri...@gmail.com>.
thanks Deepal that worked for me.

On 5/17/07, Deepal Jayasinghe <de...@opensource.lk> wrote:
>
> Hi Rishi ,
> As I can see always you are creating a new configurationContext and not
> use the server's configurationContext that is why you do not see your
> service when you browse to it. Try to get the server's
> configurationContext and add the service to it,
>
> Thanks
> Deepal
> > Hi
> > I was wondering if anyone tried programmatic deployment of Axis2
> > services without say creating an aar file. I have Axis2 deployed as a
> > web module inside my application ear file. Its supposed to run on any
> > app server. I am trying to use the code below [which will be called at
> > startup of the server] to deploy a service in Axis2.
> >
> > I am using the axis2 admin console to see if the service appears - but
> > I dont see it in the available services and if I try to send a message
> > to it - it returns with "service not found" error. I have the
> > AxisServlet deployed in my web.xml but I didnt set any axis2.xml.path
> > or axis2.repository.path. Not sure what else I need to do to get this
> > working.
> >
> > If try the aar way - the same service works great. Its only when I try
> > to go without aar I have this issue.
> >
> >  public void deployWebService(String serviceName, String operation)
> > throws AxisFault
> >  {
> >         AxisServiceGroup serviceGroup;
> >    AxisConfiguration axis2Config;
> >    String axisConfigFile = "axis2.xml";
> >    ConfigurationContext configContext;
> >   System.out.println("In deployyyyyyyyyyyyyyyyyyyyyyyyyy");
> >   try
> >   {
> >    if (configContext == null)
> >    {
> >     configContext = ConfigurationContextFactory
> >      .createConfigurationContextFromFileSystem("C:\\deployment\\axis2",
> > "C:\\deployment\\axis2\\axis2.xml");
> >     axis2Config = configContext.getAxisConfiguration();
> >    }
> >   }
> >   catch (AxisFault e)
> >   {
> >    e.printStackTrace();
> >   }
> >
> >
> >   if (serviceGroup == null)
> >   {
> >    serviceGroup = new AxisServiceGroup();
> >   }
> >   AxisService axisService = new AxisService(serviceName);
> >   axisService.setClientSide(false);
> >   axisService.setParent (serviceGroup);
> >
> >   AxisOperation axisOp =
> > AxisOperationFactory.getAxisOperation(WSDLConstants.MEP_CONSTANT_IN_OUT
> );
> >   axisOp.setName(new QName(operation));
> >   MessageReceiver messageReceiver = new RawXMLINOutMessageReceiver();
> >   axisOp.setMessageReceiver(messageReceiver);
> >   axisOp.setSoapAction("urn:"+operation);
> >   PhasesInfo pinfo = axis2Config.getPhasesInfo();
> >   pinfo.setOperationPhases(axisOp);
> >   axisService.addOperation (axisOp);
> >
> >   Parameter param1 = new Parameter(WSConstants.PARAM_SERVICE_CLASS,
> > WSConstants.STANDARD_SERVICE);
> >   axisService.addParameter(param1);
> >
> >   Parameter param2 = new Parameter(WSConstants.MAX_SERVICE,
> serviceName);
> >   axisService.addParameter(param2);
> >
> >   Parameter param3 = new Parameter(WSConstants.PARAM_QUEUED, "false");
> >   axisService.addParameter(param3);
> >
> >   Parameter param4 = new Parameter(WSConstants.PARAM_SECURITY, "None");
> >   axisService.addParameter(param4);
> >
> >   serviceGroup.addService(axisService);
> >
> >   axis2Config.addServiceGroup(serviceGroup);
> >
> >  }
> >
> >
> >
> > --
> > thanks
> > Rishi
>
> --
> Thanks,
> Deepal
> ................................................................
> "The highest tower is built one brick at a time"
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: axis-user-unsubscribe@ws.apache.org
> For additional commands, e-mail: axis-user-help@ws.apache.org
>
>


-- 
thanks
Rishi

Re: service deployment using axis2 api

Posted by Deepal Jayasinghe <de...@opensource.lk>.
Hi Rishi ,
As I can see always you are creating a new configurationContext and not
use the server's configurationContext that is why you do not see your
service when you browse to it. Try to get the server's
configurationContext and add the service to it,

Thanks
Deepal
> Hi
> I was wondering if anyone tried programmatic deployment of Axis2
> services without say creating an aar file. I have Axis2 deployed as a
> web module inside my application ear file. Its supposed to run on any
> app server. I am trying to use the code below [which will be called at
> startup of the server] to deploy a service in Axis2.
>  
> I am using the axis2 admin console to see if the service appears - but
> I dont see it in the available services and if I try to send a message
> to it - it returns with "service not found" error. I have the
> AxisServlet deployed in my web.xml but I didnt set any axis2.xml.path
> or axis2.repository.path. Not sure what else I need to do to get this
> working.
>  
> If try the aar way - the same service works great. Its only when I try
> to go without aar I have this issue.
>
>  public void deployWebService(String serviceName, String operation)
> throws AxisFault
>  {
>         AxisServiceGroup serviceGroup;
>    AxisConfiguration axis2Config;
>    String axisConfigFile = "axis2.xml";
>    ConfigurationContext configContext;
>   System.out.println("In deployyyyyyyyyyyyyyyyyyyyyyyyyy");
>   try
>   {
>    if (configContext == null)
>    {
>     configContext = ConfigurationContextFactory
>      .createConfigurationContextFromFileSystem("C:\\deployment\\axis2",
> "C:\\deployment\\axis2\\axis2.xml");
>     axis2Config = configContext.getAxisConfiguration();
>    }
>   }
>   catch (AxisFault e)
>   {
>    e.printStackTrace();
>   }
>
>   
>   if (serviceGroup == null)
>   {
>    serviceGroup = new AxisServiceGroup();
>   }
>   AxisService axisService = new AxisService(serviceName);
>   axisService.setClientSide(false);
>   axisService.setParent (serviceGroup);
>
>   AxisOperation axisOp =
> AxisOperationFactory.getAxisOperation(WSDLConstants.MEP_CONSTANT_IN_OUT);
>   axisOp.setName(new QName(operation));
>   MessageReceiver messageReceiver = new RawXMLINOutMessageReceiver();
>   axisOp.setMessageReceiver(messageReceiver);
>   axisOp.setSoapAction("urn:"+operation);
>   PhasesInfo pinfo = axis2Config.getPhasesInfo();
>   pinfo.setOperationPhases(axisOp);
>   axisService.addOperation (axisOp);
>   
>   Parameter param1 = new Parameter(WSConstants.PARAM_SERVICE_CLASS,
> WSConstants.STANDARD_SERVICE);
>   axisService.addParameter(param1);
>
>   Parameter param2 = new Parameter(WSConstants.MAX_SERVICE, serviceName);
>   axisService.addParameter(param2);
>
>   Parameter param3 = new Parameter(WSConstants.PARAM_QUEUED, "false");
>   axisService.addParameter(param3);
>
>   Parameter param4 = new Parameter(WSConstants.PARAM_SECURITY, "None");
>   axisService.addParameter(param4);
>
>   serviceGroup.addService(axisService);
>   
>   axis2Config.addServiceGroup(serviceGroup);
>
>  }
>
>
>
> -- 
> thanks
> Rishi

-- 
Thanks,
Deepal
................................................................
"The highest tower is built one brick at a time"



---------------------------------------------------------------------
To unsubscribe, e-mail: axis-user-unsubscribe@ws.apache.org
For additional commands, e-mail: axis-user-help@ws.apache.org