Define webservice interface server

web.xml configuration
<servlet>
   <servlet-name>xxx</servlet-name>
   <servlet-class>
      org.apache.cxf.transport.servlet.CXFServlet
   </servlet-class>
   <load-on-startup>1</load-on-startup>
</servlet>

<servlet-mapping>
   <servlet-name>xxx</servlet-name>
   <url-pattern>/services/*</url-pattern>
</servlet-mapping>

cxf_server_beans.xml configuration

<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" />

<bean id="MessageNotificationImpl" class="com.tydic.smpm.isag.service.impl.xxxImpl"></bean>

<jaxws:endpoint id="xxxService"
   implementor="#xxxImpl"
   address="/xxx">
   <jaxws:properties>
      <entry key="mtom-enabled" value="true"/>
   </jaxws:properties>
</jaxws:endpoint>

Interface class

@WebService(targetNamespace="http://server.xxx.com")
public interface xxx {
    public void methodReceipt(@WebParam(name="param1")String xxx, @WebParam(name="param2")Xxx xxx) throws java.rmi.RemoteException;
}

Implementation class

@javax.jws.WebService(serviceName = "xxxImpl", targetNamespace = "http://server.xxx.com",
        endpointInterface = "cn.package.xxx")
@Service("xxxImpl")
public class xxxImpl implements xxx {
    public void methodReceipt(String param1, Xxx param2) {
        
    }
}

Precautions:

1. The servlet-name and address must be the same, otherwise an error will be reported because the service cannot be found:

No service was found

2. At the beginning, the annotation @Service("xxxImpl") was not marked as bean on the implementation class, which caused the cache and business service injection to not enter

3. The values ​​in implementor and @Service("xxxImpl") must be equal, otherwise an error will be reported and no bean can be found

Guess you like

Origin blog.csdn.net/noob9527/article/details/99649248