CXF釋出服務,WebService缺少標籤
阿新 • • 發佈:2019-02-18
釋出CXF時遇到一個問題,釋出的服務,wsdl檔案中沒有<wsdl:types/><wsdl:message/>標籤,wsdl檔案如下:
對比別的wsdl檔案,發現多了wsdl:import,將其地址複製到瀏覽器位址列,發現裡面是丟失的兩個標籤,這才發現不是丟失,而是包含在wsdl:import標籤裡面。<?xml version="1.0" encoding="UTF-8"?> <wsdl:definitions xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:tns="com.oristartech.sms.core.ws.server" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:ns2="http://schemas.xmlsoap.org/soap/http" xmlns:ns1="http://server.ws.core.sms.oristartech.com/" name="dispatchService" targetNamespace="com.oristartech.sms.core.ws.server"> <wsdl:import location="http://localhost:8080/sms/webservice/isSwitch?wsdl=DispatchService.wsdl" namespace="http://server.ws.core.sms.oristartech.com/"> </wsdl:import> <wsdl:binding name="dispatchServiceSoapBinding" type="ns1:DispatchService"> <soap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"/> <wsdl:operation name="isSwitchHall"> <soap:operation soapAction="" style="document"/> <wsdl:input name="isSwitchHall"> <soap:body use="literal"/> </wsdl:input> <wsdl:output name="isSwitchHallResponse"> <soap:body use="literal"/> </wsdl:output> </wsdl:operation> </wsdl:binding> <wsdl:service name="dispatchService"> <wsdl:port binding="tns:dispatchServiceSoapBinding" name="DispatchServiceImplPort"> <soap:address location="http://localhost:8080/sms/webservice/isSwitch"/> </wsdl:port> </wsdl:service> </wsdl:definitions>
仔細查詢原因:實現類中標明瞭名稱空間@WebService(targetNamespace=“com.oristartech.sms.core.ws.server"),介面類未標明名稱空間(@WebService())
解決方案:將介面類和實現類標註名稱空間,兩者保持一致即可。
介面類程式碼:
實現類程式碼:@WebService(targetNamespace = "com.oristartech.sms.core.ws.server") public interface DispatchService { public String isSwitchHall(@WebParam(name="isSwitch")String isSwitch); }
@WebService(endpointInterface = "com.oristartech.sms.core.ws.server.DispatchService", targetNamespace = "com.oristartech.sms.core.ws.server", serviceName="dispatchService") public class DispatchServiceImpl implements DispatchService { public String isSwitchHall(@WebParam(name="isSwitch")String isSwitch) { System.out.println("===="+isSwitch); return "111"; } }