问题
I need to create a client application for consuming SOAP services. I need to create the client apps from 2 wsdl (from 2 different server applications too)
Here's the code for the first Web Service
EcommPromoWebService.java
package com.ptdam.promo.webservices;
import javax.jws.WebService;
@WebService
public interface EcommPromoWebService {
String sayHi(String text);
EcommPromoResponse inquiryPromo(EcommPromoRequest promoInquiryRequest);
}
EcommPromoWebServiceImpl.java
package com.ptdam.promo.webservices;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import javax.jws.WebService;
import com.ptdam.promo.utils.C3p0ConnectionPool;
@WebService(endpointInterface="com.ptdam.promo.webservices.EcommPromoWebService")
public class EcommPromoWebServiceImpl implements EcommPromoWebService {
@Override
public String sayHi(String text) {
System.out.println("sayHi called");
return "Hello, " + text;
}
@Override
public EcommPromoResponse inquiryPromo(EcommPromoRequest promoInquiryRequest) {
EcommPromoResponse response = new EcommPromoResponse();
Connection connInquiry = null;
// and any other stuffs
}
and here's the code for the second web service: TopupWebService.java
package ptdam.emoney.webservice.transactions;
@WebService
public interface TopupWebService {
@Permission(ServiceOperation.MANAGE_MEMBERS)
@WebMethod
@WebResult(name = "echoTestResult")
String echoTest(@WebParam(name = "tx") String tx);
@Permission(ServiceOperation.MANAGE_MEMBERS)
@WebMethod
@WebResult(name = "inquiryResult")
TopupInquiryResponse inquiry(@WebParam(name = "request") TopupInquiryRequest request);
// and any other stuffs
TopUpWebserviceImpl.java
package ptdam.emoney.webservice.transactions;
@WebService(name = "emoneytopup", serviceName = "emoneytopup")
public class TopupWebServiceImpl implements TopupWebService {
// and any other stuffs
}
I noticed that there are differences between them. One of it is the first webservice has endPointInterface
on its implementation class, while the second hasn't.
when i generate the client code for both of them, using wsimport
command, it will generate the different class too. The first web service will be generated along with the implementation class (EcommPromoWebServiceImplService
class), while the second has no implementation class generated.
So, how to generate the classes for client apps correctly for the second webservice? because without implementation class generated, i keep getting NullPointerException on my client apps (kindly check my thread here: Spring @AutoWired always null)
the wsimport
command i'm using to generate them is wsimport -keep -verbose <wsdladdress>
来源:https://stackoverflow.com/questions/44940462/spring-webservice-with-endpoint-vs-no-endpoint