如何在 SOAP 网络客户端中使用 Holder<Payload> holder
How to use Holder<Payload> holder in SOAP web client
我正在尝试弄清楚如何使用从 wsdl 文件生成的网络服务。在这个项目中,我将使用生成的 web 服务客户端发送请求。界面如下图:
public interface IConnectService {
public void processMessage(
@WebParam(name = "payload", mode =
WebParam.Mode.INOUT)
Holder<Payload> payload);
}
客户端是这样的:
public class ConnectService
extends Service
{
private final static URL CONNECTSERVICE_WSDL_LOCATION;
private final static WebServiceException CONNECTSERVICE_EXCEPTION;
private final static QName CONNECTSERVICE_QNAME = new
QName("http://xxxxxx-asi.com/services", "ConnectService");
static {
URL url = null;
WebServiceException e = null;
try {
url = new URL("http://localhost/wsdl/xxxxx");
} catch (MalformedURLException ex) {
e = new WebServiceException(ex);
}
CONNECTSERVICE_WSDL_LOCATION = url;
CONNECTSERVICE_EXCEPTION = e;
}
public ConnectService() {
super(__getWsdlLocation(), CONNECTSERVICE_QNAME);
}
public ConnectService(WebServiceFeature... features) {
super(__getWsdlLocation(), CONNECTSERVICE_QNAME, features);
}
public ConnectService(URL wsdlLocation) {
super(wsdlLocation, CONNECTSERVICE_QNAME);
}
public ConnectService(URL wsdlLocation, WebServiceFeature...
features) {
super(wsdlLocation, CONNECTSERVICE_QNAME, features);
}
public ConnectService(URL wsdlLocation, QName serviceName) {
super(wsdlLocation, serviceName);
}
public ConnectService(URL wsdlLocation, QName serviceName,
WebServiceFeature... features) {
super(wsdlLocation, serviceName, features);
}
@WebEndpoint(name = "BasicHttpBinding_IConnectService")
public IConnectService getBasicHttpBindingIConnectService() {
return super.getPort(new QName("http://xxxxxxx-
asi.com/services", "BasicHttpBinding_IConnectService"),
IConnectService.class);
}
@WebEndpoint(name = "BasicHttpBinding_IConnectService")
public IConnectService
getBasicHttpBindingIConnectService(WebServiceFeature... features) {
return super.getPort(new QName("http://xxxxxx-asi.com/services",
"BasicHttpBinding_IConnectService"), IConnectService.class,
features);
}
private static URL __getWsdlLocation() {
if (CONNECTSERVICE_EXCEPTION!= null) {
throw CONNECTSERVICE_EXCEPTION;
}
return CONNECTSERVICE_WSDL_LOCATION;
}
}
soap 请求消息结构将如图所示:enter image description here
所以我的问题是如何使用客户端通过接口方法进行调用,其中包括我的 soapmessage?据我了解,Holder object 只能接受 Payload object,它是 ProcessMessege 的子元素(如结构所示),而 ProcessMessage 是 SOAP body 的子元素。我需要将安全凭证放入 SOAP header 中,我已经这样做了。所以现在如果我使用 webservice 方法,我只能传递有效负载 object,但 Web 服务器不会接受请求,因为有效负载部分内没有凭据。任何body 可以帮助解决这个问题吗?非常感谢您的帮助!
我使用 soapmessage 处理程序和处理程序解析器解决了这个问题。处理程序可以在 soap header 中插入凭据并修改 soap body 以满足我对 soap 消息的所有要求。
我正在尝试弄清楚如何使用从 wsdl 文件生成的网络服务。在这个项目中,我将使用生成的 web 服务客户端发送请求。界面如下图:
public interface IConnectService {
public void processMessage(
@WebParam(name = "payload", mode =
WebParam.Mode.INOUT)
Holder<Payload> payload);
}
客户端是这样的:
public class ConnectService
extends Service
{
private final static URL CONNECTSERVICE_WSDL_LOCATION;
private final static WebServiceException CONNECTSERVICE_EXCEPTION;
private final static QName CONNECTSERVICE_QNAME = new
QName("http://xxxxxx-asi.com/services", "ConnectService");
static {
URL url = null;
WebServiceException e = null;
try {
url = new URL("http://localhost/wsdl/xxxxx");
} catch (MalformedURLException ex) {
e = new WebServiceException(ex);
}
CONNECTSERVICE_WSDL_LOCATION = url;
CONNECTSERVICE_EXCEPTION = e;
}
public ConnectService() {
super(__getWsdlLocation(), CONNECTSERVICE_QNAME);
}
public ConnectService(WebServiceFeature... features) {
super(__getWsdlLocation(), CONNECTSERVICE_QNAME, features);
}
public ConnectService(URL wsdlLocation) {
super(wsdlLocation, CONNECTSERVICE_QNAME);
}
public ConnectService(URL wsdlLocation, WebServiceFeature...
features) {
super(wsdlLocation, CONNECTSERVICE_QNAME, features);
}
public ConnectService(URL wsdlLocation, QName serviceName) {
super(wsdlLocation, serviceName);
}
public ConnectService(URL wsdlLocation, QName serviceName,
WebServiceFeature... features) {
super(wsdlLocation, serviceName, features);
}
@WebEndpoint(name = "BasicHttpBinding_IConnectService")
public IConnectService getBasicHttpBindingIConnectService() {
return super.getPort(new QName("http://xxxxxxx-
asi.com/services", "BasicHttpBinding_IConnectService"),
IConnectService.class);
}
@WebEndpoint(name = "BasicHttpBinding_IConnectService")
public IConnectService
getBasicHttpBindingIConnectService(WebServiceFeature... features) {
return super.getPort(new QName("http://xxxxxx-asi.com/services",
"BasicHttpBinding_IConnectService"), IConnectService.class,
features);
}
private static URL __getWsdlLocation() {
if (CONNECTSERVICE_EXCEPTION!= null) {
throw CONNECTSERVICE_EXCEPTION;
}
return CONNECTSERVICE_WSDL_LOCATION;
}
}
soap 请求消息结构将如图所示:enter image description here
所以我的问题是如何使用客户端通过接口方法进行调用,其中包括我的 soapmessage?据我了解,Holder object 只能接受 Payload object,它是 ProcessMessege 的子元素(如结构所示),而 ProcessMessage 是 SOAP body 的子元素。我需要将安全凭证放入 SOAP header 中,我已经这样做了。所以现在如果我使用 webservice 方法,我只能传递有效负载 object,但 Web 服务器不会接受请求,因为有效负载部分内没有凭据。任何body 可以帮助解决这个问题吗?非常感谢您的帮助!
我使用 soapmessage 处理程序和处理程序解析器解决了这个问题。处理程序可以在 soap header 中插入凭据并修改 soap body 以满足我对 soap 消息的所有要求。