【WSDL】03 使用注解自定义服务信息
对原来的自定义WebService设置注解:
package cn.cloud9.jax_ws.server.intf; import javax.jws.WebMethod; import javax.jws.WebParam; import javax.jws.WebResult; import javax.jws.WebService; import javax.xml.ws.BindingType; import javax.xml.ws.soap.SOAPBinding; /** * @author OnCloud9 * @description * @project WebService * @date 2022年04月23日 11:10 * * 标注此接口是Web服务接口 */ @WebService( targetNamespace = "http://service.cn.cloud9", name = "WeatherWS-Soap", portName = "WeatherWS-Soap-Port", serviceName = "WeatherWS" ) @BindingType(SOAPBinding.SOAP12HTTP_BINDING) // 发布 SOAP1。2接口 public class WeatherInterfaceImpl implements WeatherInterface{ @WebMethod( operationName = "getWeather", exclude = false ) @Override public @WebResult(name = "result") String queryWeather(@WebParam(name = "cityName") String cityName) { System.out.println("打印城市名称:" + cityName); return cityName + " 天气:晴朗"; } }
WSDL信息:
This XML file does not appear to have any style information associated with it. The document tree is shown below. <!-- Published by JAX-WS RI (http://jax-ws.java.net). RI's version is JAX-WS RI 2.2.9-b130926.1035 svn-revision#5f6196f2b90e9460065a4c2f4e30e065b245e51e. --> <!-- Generated by JAX-WS RI (http://jax-ws.java.net). RI's version is JAX-WS RI 2.2.9-b130926.1035 svn-revision#5f6196f2b90e9460065a4c2f4e30e065b245e51e. --> <definitions xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd" xmlns:wsp="http://www.w3.org/ns/ws-policy" xmlns:wsp1_2="http://schemas.xmlsoap.org/ws/2004/09/policy" xmlns:wsam="http://www.w3.org/2007/05/addressing/metadata" xmlns:soap12="http://schemas.xmlsoap.org/wsdl/soap12/" xmlns:tns="http://service.cn.cloud9" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns="http://schemas.xmlsoap.org/wsdl/" targetNamespace="http://service.cn.cloud9" name="WeatherWS"> <types> <xsd:schema> <xsd:import namespace="http://service.cn.cloud9" schemaLocation="http://127.0.0.1:9090/weather?xsd=1"/> </xsd:schema> </types> <message name="getWeather"> <part name="parameters" element="tns:getWeather"/> </message> <message name="getWeatherResponse"> <part name="parameters" element="tns:getWeatherResponse"/> </message> <portType name="WeatherWS-Soap"> <operation name="getWeather"> <input wsam:Action="http://service.cn.cloud9/WeatherWS-Soap/getWeatherRequest" message="tns:getWeather"/> <output wsam:Action="http://service.cn.cloud9/WeatherWS-Soap/getWeatherResponse" message="tns:getWeatherResponse"/> </operation> </portType> <binding name="WeatherWS-Soap-PortBinding" type="tns:WeatherWS-Soap"> <soap12:binding transport="http://schemas.xmlsoap.org/soap/http" style="document"/> <operation name="getWeather"> <soap12:operation soapAction=""/> <input> <soap12:body use="literal"/> </input> <output> <soap12:body use="literal"/> </output> </operation> </binding> <service name="WeatherWS"> <port name="WeatherWS-Soap-Port" binding="tns:WeatherWS-Soap-PortBinding"> <soap12:address location="http://127.0.0.1:9090/weather"/> </port> </service> </definitions>