本文整理汇总了Java中org.springframework.ws.client.core.WebServiceMessageCallback类的典型用法代码示例。如果您正苦于以下问题:Java WebServiceMessageCallback类的具体用法?Java WebServiceMessageCallback怎么用?Java WebServiceMessageCallback使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
WebServiceMessageCallback类属于org.springframework.ws.client.core包,在下文中一共展示了WebServiceMessageCallback类的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: listFlights
import org.springframework.ws.client.core.WebServiceMessageCallback; //导入依赖的package包/类
@SuppressWarnings("unchecked")
public List<BigInteger> listFlights() {
ObjectFactory factory = new ObjectFactory();
TListFlights tListFlights = factory.createTListFlights();
JAXBElement<TListFlights> request = factory.createListFlightsRequest(tListFlights);
JAXBElement<TFlightsResponse> response = (JAXBElement<TFlightsResponse>) webServiceTemplate
.marshalSendAndReceive(request, new WebServiceMessageCallback() {
public void doWithMessage(WebServiceMessage message) {
TransportContext context = TransportContextHolder.getTransportContext();
HttpUrlConnection connection = (HttpUrlConnection) context.getConnection();
connection.getConnection().addRequestProperty("Authorization",
BasicAuthenticationUtil.generateBasicAutenticationHeader(clientConfig.getUserName(),
clientConfig.getUserPassword()));
}
});
return response.getValue().getFlightNumber();
}
示例2: doSendAndReceive
import org.springframework.ws.client.core.WebServiceMessageCallback; //导入依赖的package包/类
@Override
protected <T> T doSendAndReceive(final MessageContext messageContext, final WebServiceConnection connection,
final WebServiceMessageCallback requestCallback, final WebServiceMessageExtractor<T> responseExtractor) throws IOException {
EbmsContext ebmsContext = EbmsContext.from(messageContext);
ebmsContext.remoteParty = Optional.of(ebmsAktoerRemoteParty.orgnr);
if (requestCallback instanceof EbmsContextAware) {
((EbmsContextAware) requestCallback).setContext(ebmsContext);
}
if (responseExtractor instanceof EbmsContextAware) {
((EbmsContextAware) responseExtractor).setContext(ebmsContext);
}
try {
return super.doSendAndReceive(messageContext, connection, requestCallback, responseExtractor);
} catch (IOException e) {
throw new MessageSenderIOException(e.getMessage(), e);
}
}
示例3: internalInvoke
import org.springframework.ws.client.core.WebServiceMessageCallback; //导入依赖的package包/类
/**
*
* @param request
* @return
*/
protected Object internalInvoke(Object request, WebServiceMessageCallback callback) {
try {
Object result;
log.trace("ExchangeRequest="+request);
if(null == callback) {
result = getWebServiceTemplate().marshalSendAndReceive(request);
} else {
result = getWebServiceTemplate().marshalSendAndReceive(request, callback);
}
return result;
} catch (SoapFaultClientException e) {
if(e.getMessage().equals("The impersonation principal name is invalid.")) {
throw new ExchangeInvalidUPNRuntimeException(e);
}
if(log.isTraceEnabled()) {
log.error("SoapFaultClientException encountered for " + request+". "+e.getMessage());
}else {
log.error("SoapFaultClientException encountered "+e.getMessage());
}
throw new ExchangeWebServicesRuntimeException(e);
}
}
示例4: process
import org.springframework.ws.client.core.WebServiceMessageCallback; //导入依赖的package包/类
public void process(Exchange exchange) throws Exception {
// Let Camel TypeConverter hierarchy handle the conversion of XML messages to Source objects
Source sourcePayload = exchange.getIn().getMandatoryBody(Source.class);
// Extract optional headers
String endpointUriHeader = exchange.getIn().getHeader(SpringWebserviceConstants.SPRING_WS_ENDPOINT_URI, String.class);
String soapActionHeader = exchange.getIn().getHeader(SpringWebserviceConstants.SPRING_WS_SOAP_ACTION, String.class);
URI wsAddressingActionHeader = exchange.getIn().getHeader(SpringWebserviceConstants.SPRING_WS_ADDRESSING_ACTION, URI.class);
URI wsReplyToHeader = exchange.getIn().getHeader(SpringWebserviceConstants.SPRING_WS_ADDRESSING_PRODUCER_REPLY_TO, URI.class);
URI wsFaultToHeader = exchange.getIn().getHeader(SpringWebserviceConstants.SPRING_WS_ADDRESSING_PRODUCER_FAULT_TO, URI.class);
Source soapHeaderSource = exchange.getIn().getHeader(SpringWebserviceConstants.SPRING_WS_SOAP_HEADER, Source.class);
WebServiceMessageCallback callback = new DefaultWebserviceMessageCallback(soapActionHeader, wsAddressingActionHeader,
wsReplyToHeader, wsFaultToHeader, soapHeaderSource, getEndpoint().getConfiguration(), exchange);
Object body;
if (endpointUriHeader != null) {
body = getEndpoint().getConfiguration().getWebServiceTemplate().sendSourceAndReceive(endpointUriHeader, sourcePayload, callback, SOURCE_EXTRACTOR);
} else {
body = getEndpoint().getConfiguration().getWebServiceTemplate().sendSourceAndReceive(sourcePayload, callback, SOURCE_EXTRACTOR);
}
if (ExchangeHelper.isOutCapable(exchange)) {
exchange.getOut().copyFrom(exchange.getIn());
exchange.getOut().setBody(body);
} else {
exchange.getIn().setBody(body);
}
}
示例5: call
import org.springframework.ws.client.core.WebServiceMessageCallback; //导入依赖的package包/类
/**
* Invoca al servicio definido en <code>info</code>, la invocación se
* realiza en otro hilo, encapsula todos los
* {@link WebServiceMessageCallback} definidos en
* {@link WSSecurityInterceptor#getWebServiceMessageCallback(Info)} para
* agregar la seguridad.
* <p>
* Este método es el punto de acceso a todos los servicios de Karaku.
* </p>
*
* @param request
* objeto que será serializado para realizar la invocación
* @param info
* información acerca del servicio.
* @param callBack
* callBack que será invocado cuando se reciba la llamada del
* servicio.
*/
public <T> void call(final Executor executor, final Object request,
final Info info, final WSCallBack<T> callBack) {
if (callBack == null) {
throw new IllegalArgumentException("CallBack no puede ser nulo");
}
executor.execute(new Runnable() {
@Override
@SuppressWarnings("unchecked")
public void run() {
try {
log.trace("Calling WebService with uri {}", info.getUrl());
WebServiceMessageCallback wsmc = interceptor
.getWebServiceMessageCallback(info);
T toRet = (T) template.marshalSendAndReceive(info.getUrl(),
request, wsmc);
log.trace("Web service call ended");
callBack.onSucess(toRet);
} catch (Exception e) {
log.debug("Error in ws", e);
callBack.onFailure(e);
}
}
});
}
示例6: createCallback
import org.springframework.ws.client.core.WebServiceMessageCallback; //导入依赖的package包/类
/**
* @param info
* @return
*/
private WebServiceMessageCallback createCallback(final String user,
final String pass) {
return new WebServiceMessageCallback() {
@Override
public void doWithMessage(WebServiceMessage message) {
addSecurity(user, pass, message);
}
};
}
示例7: marshalSendAndReceive
import org.springframework.ws.client.core.WebServiceMessageCallback; //导入依赖的package包/类
@Override
public Object marshalSendAndReceive(String uri, Object requestPayload,
WebServiceMessageCallback requestCallback) {
return getEntityResponse();
}
示例8: sendRealRequest
import org.springframework.ws.client.core.WebServiceMessageCallback; //导入依赖的package包/类
@SuppressWarnings({ "unchecked", "rawtypes" })
private <I, O> XRoadMessage<O> sendRealRequest(XRoadMessage<I> input,
XRoadServiceConfiguration xroadServiceConfiguration,
CustomCallback callback,
CustomExtractor extractor)
throws XRoadServiceConsumptionException {
try {
// Add any swaref attachments...
// First find all Objects.
for (XmlObject attachmentObj : XmlBeansUtil.getAllObjects((XmlObject) input.getContent())) {
// Introspect all methods, and find the ones that were generated during instrumentation
for (Method method : XmlBeansUtil.getSwaRefGetters(attachmentObj)) {
// Get the datahandler for the attachment
DataHandler handler = (DataHandler) method.invoke(attachmentObj);
if (handler != null) {
String field = XmlBeansUtil.getFieldName(method);
// Check whether the user has set a custom CID, if not, generate a random one and set it
String cid = XmlBeansUtil.getCid(attachmentObj, field);
if (cid == null) {
cid = AttachmentUtil.getUniqueCid();
} else {
cid = cid.startsWith("cid:") ? cid.substring(4) : cid;
}
XmlBeansUtil.setCid(attachmentObj, field, "cid:" + cid);
// Add a new attachment to the list
input.getAttachments().add(new XRoadAttachment(cid, handler));
}
}
}
XmlBeansXRoadMetadata curdata = metadata.get(xroadServiceConfiguration.getWsdlDatabase().toLowerCase()
+ xroadServiceConfiguration.getMethod().toLowerCase());
if (curdata == null) {
throw new IllegalStateException(String.format("Could not find metadata for %s.%s! Most likely the method name has been specified incorrectly.",
xroadServiceConfiguration.getWsdlDatabase().toLowerCase(),
xroadServiceConfiguration.getMethod().toLowerCase()));
}
WebServiceMessageCallback originalCallback = getNewConsumerCallback(input, xroadServiceConfiguration, curdata);
WebServiceMessageExtractor originalExtractor = new StandardXRoadConsumerMessageExtractor(curdata);
if (callback != null) {
callback.setOriginalCallback(originalCallback);
}
WebServiceMessageCallback finalCallback = callback == null ? originalCallback : callback;
if (extractor != null) {
extractor.setOriginalExtractor(originalExtractor);
}
WebServiceMessageExtractor finalExtractor = extractor == null ? originalExtractor : extractor;
return (XRoadMessage<O>) getWebServiceTemplate().sendAndReceive(xroadServiceConfiguration.getSecurityServer(),
finalCallback,
finalExtractor);
} catch (Exception e) {
XRoadServiceConsumptionException consumptionException = resolveException(e, xroadServiceConfiguration);
if (consumptionException != null) {
throw consumptionException;
}
throw new NestableRuntimeException(e);
}
}
示例9: setOriginalCallback
import org.springframework.ws.client.core.WebServiceMessageCallback; //导入依赖的package包/类
public void setOriginalCallback(WebServiceMessageCallback callback) {
this.callback = callback;
}
示例10: getWebServiceMessageCallback
import org.springframework.ws.client.core.WebServiceMessageCallback; //导入依赖的package包/类
/**
* Método que crea una nueva instancia de {@link WebServiceMessageCallback}
* y le agrega un Interceptor que se encarga de invocar al método
* {@link #addSecurity(Info, WebServiceMessage)}, el cual añade la seguridad
* necesaria.
*
* @see #addSecurity(Info, WebServiceMessage)
* @param info
* información de la llamada
* @return {@link WebServiceMessageCallback} que agrega seguridad antes de
* llamar
*/
public WebServiceMessageCallback getWebServiceMessageCallback(
final Info info) {
return createCallback(info.getUser(), info.getPassword());
}