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 red dog <re...@yahoo.com> on 2008/01/22 17:26:39 UTC

How to list embedded Axis2 services?

Hello everyone,
   
  I have 2 embedded axis 2 services in my web app. How can I list all the available services? Invoking http://localhost:8080/AppName/services/listServices returns an empty page.
   
  Here is how i define the Axis Servlet in my web.xml:
   
  <servlet>
  <servlet-name>AxisServlet</servlet-name>
  <display-name>Apache-Axis Servlet</display-name>
  <servlet-class>org.apache.axis2.transport.http.AxisServlet</servlet-class>
  
   
  <load-on-startup>2</load-on-startup>
  </servlet>
  
  <servlet-mapping>
  <servlet-name>AxisServlet</servlet-name>
  <url-pattern>/services/*</url-pattern>
  </servlet-mapping>
  <servlet-mapping> 
  <servlet-name>AxisServlet</servlet-name> 
  <url-pattern>listServices</url-pattern> 
  </servlet-mapping>
   
  Thank you,
   
  Radu

       
---------------------------------
Looking for last minute shopping deals?  Find them fast with Yahoo! Search.

Re: How to list embedded Axis2 services? [CLOSE]

Posted by red dog <re...@yahoo.com>.
Thanks a lot for your response Azeez. I'm going to close this thread now.
   
  Radu

Afkham Azeez <af...@gmail.com> wrote:
  If you extend AxisServlet, you will benefit by inheriting some of the useful utility methods in AxisServlet. You will need to override doGet/doPost. So there is nothing wrong in extending AxisServlet from a coding point of view, but from a design and best practices point of view if there is no "is-a" relationship, it is better not to go for inheritance.


Azeez

  On Jan 23, 2008 2:42 AM, red dog <re...@yahoo.com> wrote:
    Thank you Azeez. Do you see anything wrong if I extended the Axis Servlet instead?
   
  public
class ListServices extends AxisServlet {   ...
     
  public
void doGet(HttpServletRequest request,   HttpServletResponse response) 
throws ServletException {   
  StringBuffer output = 

new StringBuffer("<html><body><h1>Available Services:</h1>");   
int index = 1;   
for (Iterator iter = super.axisConfiguration.getServices().values().iterator(); iter.hasNext();){     AxisService service = (AxisService) iter.next();
  output.append(

"<p>");   output.append(index).append(
". ");   output.append(
"<a href=\"" + "services/" + service.getName() + "?wsdl\">");   output.append(service.getName());
  output.append(
"</a>");   output.append(
"<p/>");   }
  output.append(
"</body></html>");   
try{     PrintWriter printWriter = response.getWriter();
  printWriter.write(output.toString());
  printWriter.flush();
  printWriter.close();
  } 

catch (IOException ex) {   
// Make sure you log the exception, as it might be swallowed   
//log.fatal("Initial axisConfig creation failed." + ex);   
//throw new ExceptionInInitializerError(ex);   }
  
  }
  }
   
  Thank you,
   
  Radu
    
    

Afkham Azeez <af...@gmail.com> wrote:
  Simply calling the AxisServlet will not list services for you. One thing you could do is write your own servlet to do this;

public class ListServicesServlet extends HttpServlet {

private AxisConfiguration axisConfig;
 
public void init() throws ServletException {
        axisConfig =  ConfigurationContextFactory.createConfigurationContextFromFileSystem("path to ur repo", "path to your axis2.xml").getAxisConfiguration();

 }

 public void doGet(HttpServletRequest request,
                         HttpServletResponse response) throws ServletException {

         StringBuffer output = new StringBuffer("<html><body><h1>Service List</h1>");
        int index = 1;
        for (Iterator iter = axisConfig.getServices().values().iterator(); iter.hasNext();){
            AxisService service = (AxisService) iter.next();
            output.append(index).append(". ").append(service.getName());
        }
        output.append("</body></html>");
        PrintWriter printWriter = response.getWriter();
        printWriter.write(output.toString());
        printWriter.flush();
        printWriter.close();
}
}

HTH
Azeez

  On Jan 22, 2008 9:56 PM, red dog <re...@yahoo.com> wrote:
    Hello everyone,
   
  I have 2 embedded axis 2 services in my web app. How can I list all the available services? Invoking http://localhost:8080/AppName/services/listServices returns an empty page.
   
  Here is how i define the Axis Servlet in my web.xml:
   
  <
servlet>   
<servlet-name>AxisServlet</servlet-name>   
<display-name>Apache-Axis Servlet</display-name>   
<servlet-class>org.apache.axis2.transport.http.AxisServlet</servlet-class>   
  
    
<load-on-startup>2</load-on-startup>   
</servlet>   
  
<servlet-mapping>   
<servlet-name>AxisServlet</servlet-name>   
<url-pattern>/services/*</url-pattern>   
</servlet-mapping>   
<servlet-mapping>   
<servlet-name>AxisServlet</servlet-name>   
<url-pattern>listServices</url-pattern>   
</servlet-mapping>    
  Thank you,
   
  Radu
    
  
---------------------------------
  Looking for last minute shopping deals? Find them fast with Yahoo! Search.




-- 
Thanks
Afkham Azeez

http://www.wso2.org
GPG Fingerprint: 643F C2AF EB78 F886 40C9  B2A2 4AE2 C887 665E 0760 


    
  
---------------------------------
  Never miss a thing. Make Yahoo your homepage. 




-- 
Thanks
Afkham Azeez

http://www.wso2.org
GPG Fingerprint: 643F C2AF EB78 F886 40C9  B2A2 4AE2 C887 665E 0760 

       
---------------------------------
Never miss a thing.   Make Yahoo your homepage.

Re: How to list embedded Axis2 services?

Posted by Afkham Azeez <af...@gmail.com>.
If you extend AxisServlet, you will benefit by inheriting some of the useful
utility methods in AxisServlet. You will need to override doGet/doPost. So
there is nothing wrong in extending AxisServlet from a coding point of view,
but from a design and best practices point of view if there is no "is-a"
relationship, it is better not to go for inheritance.


Azeez

On Jan 23, 2008 2:42 AM, red dog <re...@yahoo.com> wrote:

> Thank you Azeez. Do you see anything wrong if I extended the Axis Servlet
> instead?
>
> * public
> * *class* ListServices *extends* AxisServlet { ...
>
> * public
> * *void* doGet(HttpServletRequest request, HttpServletResponse response)
> *throws* ServletException {
> StringBuffer output =
> *new* StringBuffer("<html><body><h1>Available Services:</h1>");
> *int* index = 1;
> *for* (Iterator iter = *super*.axisConfiguration.getServices().values().iterator();
> iter.hasNext();){ AxisService service = (AxisService) iter.next();
> output.append(
> "<p>"); output.append(index).append(
> ". "); output.append(
> "<a href=\"" + "services/" + service.getName() + "?wsdl\">");
> output.append(service.getName());
> output.append(
> "</a>"); output.append(
> "<p/>"); }
> output.append(
> "</body></html>");
> *try*{ PrintWriter printWriter = response.getWriter();
> printWriter.write(output.toString());
> printWriter.flush();
> printWriter.close();
> }
> *catch* (IOException ex) {
> // Make sure you log the exception, as it might be swallowed
> //log.fatal("Initial axisConfig creation failed." + ex);
> //throw new ExceptionInInitializerError(ex); }
>  }
> }
>
> Thank you,
>
> Radu
>
>
> *Afkham Azeez <af...@gmail.com>* wrote:
>
> Simply calling the AxisServlet will not list services for you. One thing
> you could do is write your own servlet to do this;
>
> public class ListServicesServlet extends HttpServlet {
>
> private AxisConfiguration axisConfig;
>
> public void init() throws ServletException {
>         axisConfig =
> ConfigurationContextFactory.createConfigurationContextFromFileSystem("path
> to ur repo", "path to your axis2.xml").getAxisConfiguration();
>
>  }
>
>  public void doGet(HttpServletRequest request,
>                          HttpServletResponse response) throws
> ServletException {
>
>          StringBuffer output = new StringBuffer("<html><body><h1>Service
> List</h1>");
>         int index = 1;
>         for (Iterator iter = axisConfig.getServices().values().iterator();
> iter.hasNext();){
>             AxisService service = (AxisService) iter.next();
>             output.append(index).append(". ").append(service.getName());
>         }
>         output.append("</body></html>");
>         PrintWriter printWriter = response.getWriter();
>         printWriter.write(output.toString());
>         printWriter.flush();
>         printWriter.close();
> }
> }
>
> HTH
> Azeez
>
> On Jan 22, 2008 9:56 PM, red dog <re...@yahoo.com> wrote:
>
> > Hello everyone,
> >
> > I have 2 embedded axis 2 services in my web app. How can I list all the
> > available services? Invoking
> > http://localhost:8080/AppName/services/listServices returns an empty
> > page.
> >
> > Here is how i define the Axis Servlet in my web.xml:
> >
> > <
> > servlet>
> > <servlet-name>AxisServlet</servlet-name>
> > <display-name>Apache-Axis Servlet</display-name>
> > <servlet-class>org.apache.axis2.transport.http.AxisServlet</
> > servlet-class>
> >
> > <load-on-startup>2</load-on-startup>
> > </servlet>
> > <servlet-mapping>
> > <servlet-name>AxisServlet</servlet-name>
> > <url-pattern>/services/*</url-pattern>
> > </servlet-mapping>
> > <servlet-mapping>
> > <servlet-name>AxisServlet</servlet-name>
> > <url-pattern>listServices</url-pattern>
> > </servlet-mapping>
> > Thank you,
> >
> > Radu
> >  ------------------------------
> > Looking for last minute shopping deals? Find them fast with Yahoo!
> > Search.<http://us.rd.yahoo.com/evt=51734/*http://tools.search.yahoo.com/newsearch/category.php?category=shopping>
> >
>
>
>
> --
> Thanks
> Afkham Azeez
>
> http://www.wso2.org
> GPG Fingerprint: 643F C2AF EB78 F886 40C9  B2A2 4AE2 C887 665E 0760
>
>
> ------------------------------
> Never miss a thing. Make Yahoo your homepage.<http://us.rd.yahoo.com/evt=51438/*http://www.yahoo.com/r/hs>
>



-- 
Thanks
Afkham Azeez

http://www.wso2.org
GPG Fingerprint: 643F C2AF EB78 F886 40C9  B2A2 4AE2 C887 665E 0760

Re: How to list embedded Axis2 services?

Posted by red dog <re...@yahoo.com>.
Thank you Azeez. Do you see anything wrong if I extended the Axis Servlet instead?
   
  public class ListServices extends AxisServlet {
  ...
   
  public void doGet(HttpServletRequest request,
  HttpServletResponse response) throws ServletException {
  
  StringBuffer output = new StringBuffer("<html><body><h1>Available Services:</h1>");
  int index = 1;
  for (Iterator iter = super.axisConfiguration.getServices().values().iterator(); iter.hasNext();){
  AxisService service = (AxisService) iter.next();
  output.append("<p>");
  output.append(index).append(". ");
  output.append("<a href=\"" + "services/" + service.getName() + "?wsdl\">");
  output.append(service.getName());
  output.append("</a>");
  output.append("<p/>");
  }
  output.append("</body></html>");
  try{
  PrintWriter printWriter = response.getWriter();
  printWriter.write(output.toString());
  printWriter.flush();
  printWriter.close();
  } catch (IOException ex) {
  // Make sure you log the exception, as it might be swallowed
  //log.fatal("Initial axisConfig creation failed." + ex);
  //throw new ExceptionInInitializerError(ex);
  }
  
  }
  }
   
  Thank you,
   
  Radu
  

Afkham Azeez <af...@gmail.com> wrote:
  Simply calling the AxisServlet will not list services for you. One thing you could do is write your own servlet to do this;

public class ListServicesServlet extends HttpServlet {

private AxisConfiguration axisConfig;
 
public void init() throws ServletException {
        axisConfig =  ConfigurationContextFactory.createConfigurationContextFromFileSystem("path to ur repo", "path to your axis2.xml").getAxisConfiguration();

 }

 public void doGet(HttpServletRequest request,
                         HttpServletResponse response) throws ServletException {

         StringBuffer output = new StringBuffer("<html><body><h1>Service List</h1>");
        int index = 1;
        for (Iterator iter = axisConfig.getServices().values().iterator(); iter.hasNext();){
            AxisService service = (AxisService) iter.next();
            output.append(index).append(". ").append(service.getName());
        }
        output.append("</body></html>");
        PrintWriter printWriter = response.getWriter();
        printWriter.write(output.toString());
        printWriter.flush();
        printWriter.close();
}
}

HTH
Azeez

  On Jan 22, 2008 9:56 PM, red dog <re...@yahoo.com> wrote:
    Hello everyone,
   
  I have 2 embedded axis 2 services in my web app. How can I list all the available services? Invoking http://localhost:8080/AppName/services/listServices returns an empty page.
   
  Here is how i define the Axis Servlet in my web.xml:
   
  <
servlet>   
<servlet-name>AxisServlet</servlet-name>   
<display-name>Apache-Axis Servlet</display-name>   
<servlet-class>org.apache.axis2.transport.http.AxisServlet</servlet-class>   
  
    
<load-on-startup>2</load-on-startup>   
</servlet>   
  
<servlet-mapping>   
<servlet-name>AxisServlet</servlet-name>   
<url-pattern>/services/*</url-pattern>   
</servlet-mapping>   
<servlet-mapping>   
<servlet-name>AxisServlet</servlet-name>   
<url-pattern>listServices</url-pattern>   
</servlet-mapping>    
  Thank you,
   
  Radu
    
  
---------------------------------
  Looking for last minute shopping deals? Find them fast with Yahoo! Search.




-- 
Thanks
Afkham Azeez

http://www.wso2.org
GPG Fingerprint: 643F C2AF EB78 F886 40C9  B2A2 4AE2 C887 665E 0760 

       
---------------------------------
Never miss a thing.   Make Yahoo your homepage.

Re: How to list embedded Axis2 services?

Posted by Afkham Azeez <af...@gmail.com>.
Simply calling the AxisServlet will not list services for you. One thing you
could do is write your own servlet to do this;

public class ListServicesServlet extends HttpServlet {

private AxisConfiguration axisConfig;

public void init() throws ServletException {
        axisConfig =
ConfigurationContextFactory.createConfigurationContextFromFileSystem("path
to ur repo", "path to your axis2.xml").getAxisConfiguration();

 }

 public void doGet(HttpServletRequest request,
                         HttpServletResponse response) throws
ServletException {

         StringBuffer output = new StringBuffer("<html><body><h1>Service
List</h1>");
        int index = 1;
        for (Iterator iter = axisConfig.getServices().values().iterator();
iter.hasNext();){
            AxisService service = (AxisService) iter.next();
            output.append(index).append(". ").append(service.getName());
        }
        output.append("</body></html>");
        PrintWriter printWriter = response.getWriter();
        printWriter.write(output.toString());
        printWriter.flush();
        printWriter.close();
}
}

HTH
Azeez

On Jan 22, 2008 9:56 PM, red dog <re...@yahoo.com> wrote:

> Hello everyone,
>
> I have 2 embedded axis 2 services in my web app. How can I list all the
> available services? Invoking
> http://localhost:8080/AppName/services/listServices returns an empty page.
>
> Here is how i define the Axis Servlet in my web.xml:
>
> <
> servlet>
> <servlet-name>AxisServlet</servlet-name>
> <display-name>Apache-Axis Servlet</display-name>
> <servlet-class>org.apache.axis2.transport.http.AxisServlet</servlet-class>
>
> <load-on-startup>2</load-on-startup>
> </servlet>
> <servlet-mapping>
> <servlet-name>AxisServlet</servlet-name>
> <url-pattern>/services/*</url-pattern>
> </servlet-mapping>
> <servlet-mapping>
> <servlet-name>AxisServlet</servlet-name>
> <url-pattern>listServices</url-pattern>
> </servlet-mapping>
> Thank you,
>
> Radu
>
> ------------------------------
> Looking for last minute shopping deals? Find them fast with Yahoo! Search.<http://us.rd.yahoo.com/evt=51734/*http://tools.search.yahoo.com/newsearch/category.php?category=shopping>
>



-- 
Thanks
Afkham Azeez

http://www.wso2.org
GPG Fingerprint: 643F C2AF EB78 F886 40C9  B2A2 4AE2 C887 665E 0760