webservice 接口 开发 服务端


package com.test.inf;

@WebService(targetNamespace = "http://inf.test.com/")
public interface testService{

    public abstract String test(@WebParam(name="arg0") String name);
    
}

接口参数也可以是一个java 对象,可以自定义。

@WebService
public class testServiceImpl implements testService{
      public String test(String name)  {
           //业务处理
    }
}    

配置文件:

<?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:context="http://www.springframework.org/schema/context"
    xmlns:jaxws="http://cxf.apache.org/jaxws"
    xsi:schemaLocation="http://www.springframework.org/schema/beans
    http://www.springframework.org/schema/beans/spring-beans.xsd
    http://www.springframework.org/schema/context
    http://www.springframework.org/schema/context/spring-context.xsd
    http://cxf.apache.org/jaxws
    http://cxf.apache.org/schemas/jaxws.xsd">

    <import resource="classpath:META-INF/cxf/cxf.xml" />
    <import resource="classpath:META-INF/cxf/cxf-extension-soap.xml" />
    <import resource="classpath:META-INF/cxf/cxf-servlet.xml" />

    <context:component-scan base-package="com.test.inf" />
    <jaxws:endpoint id="syncUserService"
        implementor="com.test.inf.testServiceImpl " address="/testInf">
        <jaxws:inInterceptors>
            <bean name="loggingInInterceptor" class="org.apache.cxf.interceptor.LoggingInInterceptor"/>
        </jaxws:inInterceptors>
        <jaxws:outInterceptors>
            <bean name="loggingOutInterceptor" class="org.apache.cxf.interceptor.LoggingOutInterceptor" />
        </jaxws:outInterceptors>
    </jaxws:endpoint>

    
</beans>

接口地址 以 ?testInf.wsdl 结尾

   

 


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM