CFX WebService Getting started with detailed steps __web

Source: Internet
Author: User
Tags soap

The first step is to import CFX related packages download address: http://cxf.apache.org/download.html

Second Step configuration Web.xml

<!--CFX Webserivice-->

<servlet>

<description>apache CXF endpoint</description>

<display-name>cxf</display-name>

<servlet-name>cxf</servlet-name>

<servlet-class>

Org.apache.cxf.transport.servlet.CXFServlet

</servlet-class>

<load-on-startup>1</load-on-startup>

</servlet>

<servlet-mapping>

<servlet-name>cxf</servlet-name>

<url-pattern>/services/*</url-pattern>

</servlet-mapping>

<session-config>

<session-timeout>60</session-timeout>

</session-config>

The third step joins Cfx-servlet.xml under Web-inf

<?xml version= "1.0" encoding= "UTF-8"?>

<beans xmlns= "Http://www.springframework.org/schema/beans"

Xmlns:xsi= "Http://www.w3.org/2001/XMLSchema-instance"

Xmlns:jaxws= "Http://cxf.apache.org/jaxws"

xmlns:soap= "Http://cxf.apache.org/bindings/soap"

Xsi:schemalocation= "

Http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd

Http://cxf.apache.org/bindings/soap http://cxf.apache.org/schemas/configuration/soap.xsd

Http://cxf.apache.org/jaxws

Http://cxf.apache.org/schemas/jaxws.xsd ">

<!--; Service Interface-->

<jaxws:server id= "Jaxwsservice" serviceclass= "Com.uu.service.IService"

address= "/test" > <!-address release Level Two address for the service full address for/project publication name/CFX intercept address/address (CFX intercept address is configured in Web.xml tab url-pattern)-->

<jaxws:serviceBean>

<!--service Implementation class-->

<bean class= "Com.uu.service.impl.Service"/>

</jaxws:serviceBean>

</jaxws:server>

</beans>

Fourth step to write interface and implementation class

IService interface

package Com.uu.service;

@WebService

Public Interface IService

{

@WebMethod

String Test (@WebParam string param);

}

Service Implementation class:

package Com.uu.service.impl;

Public class Quoteservice implements Iquoteservice

{

@Override

Public String Test (string param)

{

return "Hello," +param;

}

}

Step Fifth Unit Test

@Test

Public void test3 ()

{

Jaxwsproxyfactorybean factory = new Jaxwsproxyfactorybean ();

Factory.getininterceptors (). Add (new loggingininterceptor ());

Factory.getoutinterceptors (). Add (new loggingoutinterceptor ());

Factory.setserviceclass (IService. Class);

Factory.setaddress ("http://localhost:8081/project name/services/test");

IService client = (iservice) factory.create ();

String msg = client.test ("Kinglo");

SYSTEM.OUT.PRINTLN (msg);

}

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.