我试图让客户端连接到Web服务并在服务器上使用SetFlight方法。
环境是Intellij Ultimate,Java 7和JAXWS。从WSDL生成类已经完成。
在生成的类中,我有两个服务:
@WebServiceClient(name = "FOService", targetNamespace = "http://temporaryuri.org.au/", wsdlLocation = "http://fovanil.com/FOService.svc?wsdl")
public class FOService
extends Service
{
private final static URL FOSERVICE_WSDL_LOCATION;
private final static WebServiceException FOSERVICE_EXCEPTION;
private final static QName FOSERVICE_QNAME = new QName("http://temporaryuri.org.au/", "FOService");
static {
...
和IFO服务
@WebService(name = "IFOService", targetNamespace = "urn:fo.com.au/schema/common")
@SOAPBinding(parameterStyle = SOAPBinding.ParameterStyle.BARE)
@XmlSeeAlso({
ObjectFactory.class
})
public interface IFOService {
/**
*
* @param parameters
* @return
* returns svc.SetFlightResponse
*/
@WebMethod(operationName = "SetFlight", action = "http://fo.com.au/SetFlight")
@WebResult(name = "SetFlightResponse", targetNamespace = "urn:fo.com.au/schema/common/types", partName = "parameters")
public SetFlightResponse SetFlight(
@WebParam(name = "SetFlightRequest", targetNamespace = "urn:fo.com.au/schema/common/types", partName = "parameters")
SetFlightRequest parameters);
}
我已经看了一些实现客户端https://docs.oracle.com/javaee/5/tutorial/doc/bnayn.html的例子,但这有所不同。
我原以为使用这个会是:
IFOSerice service = new IFOService();
service.SetFlight(someinstanceofflight); //setFlight is not a available method
如何创建客户端并使用SetFlight方法?
这段代码有效:
SetFORequest request = new SetFORequest();
SetFOResponse response = new SetFOResponse();
request.setFO(flight);
FOService foService = new FOService();
IfoService ifoService = foService.getWSHttpBindingIFOService();
ifoService.setFO(request);