CXF环境搭建网上的帖子大致相同,参考:
https://blog.csdn.net/maple_fix/article/details/79884320
遇到的问题,启动项目报以下错误:
***************************
APPLICATION FAILED TO START
***************************
Description:
Method servletEndpointRegistrar in org.springframework.boot.actuate.autoconfigure.endpoint.web.ServletEndpointManagementContextConfiguration$WebMvcServletEndpointManagementContextConfiguration required a bean of type 'org.springframework.boot.autoconfigure.web.servlet.DispatcherServletPathProvider' that could not be found.
- Bean method 'mainDispatcherServletPathProvider' not loaded because Default DispatcherServlet found non dispatcher servlet bean dispatcherServlet
Action:
Consider revisiting the conditions above or defining a bean of type 'org.springframework.boot.autoconfigure.web.servlet.DispatcherServletPathProvider' in your configuration.
经查阅资料找到 解决办法,参考博客https://blog.csdn.net/qq_37394874/article/details/86523678:
将spring boot 版本换成 2.0.1RELEASE
<!-- spring boot 基础依赖包 -->
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<!-- <version>2.0.3.RELEASE</version> 使用此版本,集成webservice时启动报错,所以改为使用2.0.1版本-->
<version>2.0.1.RELEASE</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
cxf jar包使用以下两个版本都可以:
<!-- cxf依赖 3.1.12 START-->
<!-- <dependency>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-rt-frontend-jaxws</artifactId>
<version>3.1.12</version>
</dependency>
<dependency>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-rt-transports-http</artifactId>
<version>3.1.12</version>
</dependency>
<!-- cxf依赖 3.1.12 END-->
-->
<!-- CXF 3.2.4 START-->
<dependency>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-spring-boot-starter-jaxws</artifactId>
<version>3.2.4</version>
</dependency>
<!-- CXF 3.2.4 END-->
至此,问题解决了:
访问如下地址也能正确看到wsdl
http://localhost:8081/dc/webservice/user?wsdl
2019-10-21:
FS项目集成webservice时启动再次遇到问题,百度到其他博客的解决办法:
application.properties中添加如下配置
cxf.path=/webservice
SpringBoot版本和cxf版本:
<!-- spring boot 基础依赖包 -->
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.0.3.RELEASE</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<!-- CXF webservice -->
<dependency>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-spring-boot-starter-jaxws</artifactId>
<version>3.2.4</version>
</dependency>
使用postman测试webservice接口:
body中的参数值:
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:pm="http://service.fs.gohealth.com/">
<soapenv:Header></soapenv:Header>
<soapenv:Body>
<pm:HIPMessageServer>
<action>ProviderDetailsQuery</action>
<message><![CDATA[<PRPM_IN306010UV01 xmlns="urn:hl7-org:v3" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" ITSVersion="XML_1.0" xsi:schemaLocation="urn:hl7-org:v3 ../multicacheschemas/PRPM_IN306010UV01.xsd"><id root="1ee83ff1-08ab-4fe7-b573-ea777e9bad51" extension="9D73520B-D489-4B70-8F4B-7B5C2D7961B5"/><creationTime value="20080625141610"/><versionCode code="V3-2007-05"/><interactionId extension="PRPM_IN306010UV01" root="2.16.840.1.113883.1.6" displayable="true"/><profileId root="2.16.124.113635.1.1.100.0.2.2"/><processingCode code="P"/><processingModeCode code="T"/><acceptAckCode code="AL"/><receiver typeCode="RCV"><telecom></telecom><device classCode="DEV" determinerCode="INSTANCE"><id root="1.2.840.114350.1.13.999.567"/></device></receiver><sender typeCode="SND"><telecom></telecom><device classCode="DEV" determinerCode="INSTANCE"><id root="1.2.840.114350.1.13.999.234"/></device></sender><controlActProcess classCode="CACT" moodCode="EVN"><code code="PRPM_TE306010UV01" codeSystem="2.16.840.1.113883.1.6"/><queryByParameterPayload><statusCode code="new"/><administrativeGender><value code="1" codeSystem="2.16.156.10011.2.3.3.4" displayName="男性"/><semanticsText>PrincipalPerson.administrativeGenderCode</semanticsText></administrativeGender><dOB><value value="20010101"/><semanticsText>PrincipalPerson.birthDate</semanticsText></dOB><providerID><value root="2.16.156.10011.1.4" extension="120109197706015518"/><semanticsText>HealthCareProvider.id</semanticsText></providerID><providerName><value>李医生</value><semanticsText>PrincipalPerson.name</semanticsText></providerName></queryByParameterPayload></controlActProcess></PRPM_IN306010UV01>]]></message>
</pm:HIPMessageServer>
</soapenv:Body>
</soapenv:Envelope>
body中的参数格式:
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:pm="http://service.fs.gohealth.com/">
<soapenv:Header></soapenv:Header>
<soapenv:Body>
<pm:HIPMessageServer>
<action>ProviderDetailsQuery</action>
<message><![CDATA[xxxxxxml]]></message>
</pm:HIPMessageServer>
</soapenv:Body>
</soapenv:Envelope>