Portname and Servicename are not getting changed in Java WebService
I am learning JAVA WEB SERVICE especially SOAP. As per the tutorial, we can customize the WSDL, like we can override the deafult post name and service name by using the WebService
annotation. So I tried like the following:
package practice;
import java.util.List;
import javax.jws.WebMethod; import javax.jws.WebService;
import practice.business.WebTestImpl; @WebService(name="getBooksName",portName="getBooksPortName",serviceName="getBooksService")
public class WebCaller
{ WebTestImpl wimpl=new WebTestImpl();
@WebMethod
public List getBooks(String category)
{ return wimpl.getBooks(category);
} }
But still the default service name and port name have not changed. What can be the reason for this? The WSDL which got generated is as below:
<definitions targetNamespace="http://practice/" name="WebCallerService"><types><xsd:schema><xsd:import namespace="http://practice/" schemaLocation="http://adminib-v7gnsh2:8075/WebTest/WebCallerService?xsd=1"/></xsd:schema></types><message name="getBooks"><part name="parameters" element="tns:getBooks"/></message><message name="getBooksResponse"><part name="parameters" element="tns:getBooksResponse"/></message><portType name="WebCaller"><operation name="getBooks"><input wsam:Action="http://practice/WebCaller/getBooksRequest" message="tns:getBooks"/><output wsam:Action="http://practice/WebCaller/getBooksResponse" message="tns:getBooksResponse"/></operation></portType><binding name="WebCallerPortBinding" type="tns:WebCaller"><soap:binding transport="http://schemas.xmlsoap.org/soap/http" style="document"/><operation name="getBooks"><soap:operation soapAction=""/><input><soap:body use="literal"/></input><output><soap:body use="literal"/></output></operation></binding><service name="WebCallerService"><port name="WebCallerPort" binding="tns:WebCallerPortBinding"><soap:address location="http://adminib-v7gnsh2:8075/WebTest/WebCallerService"/></port></service></definitions>
I am using Eclipse IDE and Glassfish server.
If you have also descriptors files (eg webservices.xml), the settings for the ports in code are overwritten with those from the descriptior files. An example of configuring web services is the solution in the OSCM Service Catalog. See https://github.com/servicecatalog/development/tree/master/oscm-webservices
More about the Open Source Project OSCM Cloud Service Management Software
链接地址: http://www.djcxy.com/p/56664.html上一篇: 带回调的.NET异步web服务调用