serviceclient.java
来自「开源的axis2框架的源码。用于开发WEBSERVER」· Java 代码 · 共 832 行 · 第 1/3 页
JAVA
832 行
* @param options (non-<code>null</code>)
*/
public void setOptions(Options options) {
this.options = options;
}
/**
* Get the basic client configuration from this service interaction.
*
* @return options
*/
public Options getOptions() {
return options;
}
/**
* Set a client configuration to override the normal options used by an
* operation client. Any values set in this configuration will be used for
* each client, with the standard values for the client still used for any
* values not set in the override configuration.
*
* @param overrideOptions the Options to use
*/
public void setOverrideOptions(Options overrideOptions) {
this.overrideOptions = overrideOptions;
}
/**
* Get the client configuration used to override the normal options set by
* an operation client.
*
* @return override options
*/
public Options getOverrideOptions() {
return overrideOptions;
}
/**
* Engage a module for this service client.
*
* @deprecated Please use String version instead
* @param moduleName name of the module to engage
* @throws AxisFault if something goes wrong
*/
public void engageModule(QName moduleName) throws AxisFault {
engageModule(moduleName.getLocalPart());
}
/**
* Engage a module for this service client.
*
* @param moduleName name of the module to engage
* @throws AxisFault if something goes wrong
*/
public void engageModule(String moduleName) throws AxisFault {
synchronized (this) {
AxisModule module = axisConfig.getModule(moduleName);
if (module != null) {
axisService.engageModule(module);
} else {
throw new AxisFault("Unable to engage module : " + moduleName);
}
}
}
/**
* Disengage a module for this service client
*
* @deprecated Please use String version instead
* @param moduleName name of Module to disengage
*/
public void disengageModule(QName moduleName) {
disengageModule(moduleName.getLocalPart());
}
/**
* Disengage a module for this service client
*
* @param moduleName name of Module to disengage
*/
public void disengageModule(String moduleName) {
AxisModule module = axisConfig.getModule(moduleName);
if (module != null) {
try {
axisService.disengageModule(module);
} catch (AxisFault axisFault) {
log.error(axisFault.getMessage(), axisFault);
}
}
}
/**
* Add an arbitrary XML element as a header to be sent with outgoing
* messages.
*
* @param header header to be sent (non-<code>null</code>)
*/
public void addHeader(OMElement header) {
if (headers == null) {
headers = new ArrayList();
}
headers.add(header);
}
/**
* Add SOAP Header to be sent with outgoing messages.
*
* @param header header to be sent (non-<code>null</code>)
*/
public void addHeader(SOAPHeaderBlock header) {
if (headers == null) {
headers = new ArrayList();
}
headers.add(header);
}
/**
* Remove all headers for outgoing message.
*/
public void removeHeaders() {
if (headers != null) {
headers.clear();
}
}
/**
* Add a simple header containing some text to be sent with interactions.
*
* @param headerName name of header to add
* @param headerText text content for header
* @throws AxisFault in case of error
*/
public void addStringHeader(QName headerName, String headerText) throws AxisFault {
if (headerName.getNamespaceURI() == null || "".equals(headerName.getNamespaceURI())) {
throw new AxisFault(
"Failed to add string header, you have to have namespaceURI for the QName");
}
OMElement omElement = OMAbstractFactory.getOMFactory().createOMElement(headerName, null);
omElement.setText(headerText);
addHeader(omElement);
}
/**
* Directly invoke an anonymous operation with a Robust In-Only MEP. This
* method just sends your supplied XML and possibly receives a fault. For
* more control, you can instead create a client for the operation and use
* that client to execute the send.
*
* @param elem XML to send
* @throws AxisFault if something goes wrong while sending, or if a fault is
* received in response (per the Robust In-Only MEP).
* @see #createClient(QName)
*/
public void sendRobust(OMElement elem) throws AxisFault {
sendRobust(ANON_ROBUST_OUT_ONLY_OP, elem);
}
/**
* Directly invoke a named operation with a Robust In-Only MEP. This method
* just sends your supplied XML and possibly receives a fault. For more
* control, you can instead create a client for the operation and use that
* client to execute the send.
*
* @param operation name of operation to be invoked (non-<code>null</code>)
* @param elem XML to send
* @throws AxisFault if something goes wrong while sending it or if a fault is
* received in response (per the Robust In-Only MEP).
* @see #createClient(QName)
*/
public void sendRobust(QName operation, OMElement elem) throws AxisFault {
MessageContext mc = new MessageContext();
fillSOAPEnvelope(mc, elem);
OperationClient mepClient = createClient(operation);
mepClient.addMessageContext(mc);
mepClient.execute(true);
}
/**
* Directly invoke an anonymous operation with an In-Only MEP. This method
* just sends your supplied XML without the possibility of any response from
* the service (even an error - though you can still get client-side errors
* such as "Host not found"). For more control, you can instead create a
* client for the operation and use that client to execute the send.
*
* @param elem XML to send
* @throws AxisFault ff something goes wrong trying to send the XML
* @see #createClient(QName)
*/
public void fireAndForget(OMElement elem) throws AxisFault {
fireAndForget(ANON_OUT_ONLY_OP, elem);
}
/**
* Directly invoke a named operation with an In-Only MEP. This method just
* sends your supplied XML without the possibility of any response from the
* service (even an error - though you can still get client-side errors such
* as "Host not found"). For more control, you can instead create a client
* for the operation and use that client to execute the send.
*
* @param operation name of operation to be invoked (non-<code>null</code>)
* @param elem XML to send
* @throws AxisFault if something goes wrong trying to send the XML
* @see #createClient(QName)
*/
public void fireAndForget(QName operation, OMElement elem) throws AxisFault {
// look up the appropriate axisop and create the client
OperationClient mepClient = createClient(operation);
// create a message context and put the payload in there along with any
// headers
MessageContext mc = new MessageContext();
fillSOAPEnvelope(mc, elem);
// add the message context there and have it go
mepClient.addMessageContext(mc);
mepClient.execute(false);
}
/**
* Directly invoke an anonymous operation with an In-Out MEP. This method
* sends your supplied XML and receives a response. For more control, you
* can instead create a client for the operation and use that client to
* execute the exchange.
*
* @param elem the data to send (becomes the content of SOAP body)
* @return response
* @throws AxisFault in case of error
* @see #createClient(QName)
*/
public OMElement sendReceive(OMElement elem) throws AxisFault {
return sendReceive(ANON_OUT_IN_OP, elem);
}
/**
* Directly invoke a named operationQName with an In-Out MEP. This method sends
* your supplied XML and receives a response. For more control, you can
* instead create a client for the operationQName and use that client to execute
* the exchange.
*
* @param operationQName name of operationQName to be invoked (non-<code>null</code>)
* @param xmlPayload the data to send (becomes the content of SOAP body)
* @return response OMElement
* @throws AxisFault in case of error
*/
public OMElement sendReceive(QName operationQName, OMElement xmlPayload)
throws AxisFault {
MessageContext messageContext = new MessageContext();
fillSOAPEnvelope(messageContext, xmlPayload);
OperationClient operationClient = createClient(operationQName);
operationClient.addMessageContext(messageContext);
operationClient.execute(true);
MessageContext response = operationClient
.getMessageContext(WSDLConstants.MESSAGE_LABEL_IN_VALUE);
if(options.isCallTransportCleanup()){
response.getEnvelope().build();
cleanupTransport();
return response.getEnvelope().getBody().getFirstElement();
} else {
return response.getEnvelope().getBody().getFirstElement();
}
}
/**
* Directly invoke an anonymous operation with an In-Out MEP without waiting
* for a response. This method sends your supplied XML with response
* notification to your callback handler. For more control, you can instead
* create a client for the operation and use that client to execute the
* exchange.
*
* @param elem the data to send (becomes the content of SOAP body)
* @param callback a Callback which will be notified upon completion
* @throws AxisFault in case of error
* @see #createClient(QName)
* @deprecated Please use the AxisCallback interface rather than Callback, which has been deprecated
*/
public void sendReceiveNonBlocking(OMElement elem, Callback callback)
throws AxisFault {
sendReceiveNonBlocking(ANON_OUT_IN_OP, elem, callback);
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?