有没有可能将WS-Addressing与解耦的端点一起使用,但不使用Jetty,只使用ServletDestination?
我得到了以下异常,并且我的SOAP头包含任何正常的replyTo地址:
2014-05-26 17:20:35,733 ERROR [org.apache.cxf.transport.http.HTTPTransportFactory] (server_Worker-1) Cannot find any registered HttpDestinationFactory from the Bus.
2014-05-26 17:20:35,733 WARN [org.apache.cxf.ws.addressing.MAPAggregator] (server_Worker-1) decoupled endpoint creation failed:
java.io.IOException: Cannot find any registered HttpDestinationFactory from the Bus.
at org.apache.cxf.transport.http.HTTPTransportFactory.getDestination(HTTPTransportFactory.java:296)
at org.apache.cxf.ws.addressing.impl.MAPAggregatorImpl.getDestination(MAPAggregatorImpl.java:990)
at org.apache.cxf.ws.addressing.impl.MAPAggregatorImpl.setUpDecoupledDestination(MAPAggregatorImpl.java:961)
at org.apache.cxf.ws.addressing.impl.MAPAggregatorImpl.createDecoupledDestination(MAPAggregatorImpl.java:945)
at org.apache.cxf.ws.addressing.impl.MAPAggregatorImpl.getReplyTo(MAPAggregatorImpl.java:930)
at org.apache.cxf.ws.addressing.impl.MAPAggregatorImpl.addRoleSpecific(MAPAggregatorImpl.java:850)
at org.apache.cxf.ws.addressing.impl.MAPAggregatorImpl.aggregate(MAPAggregatorImpl.java:617)
at org.apache.cxf.ws.addressing.impl.MAPAggregatorImpl.mediate(MAPAggregatorImpl.java:448)
at org.apache.cxf.ws.addressing.impl.MAPAggregatorImpl.handleMessage(MAPAggregatorImpl.java:143)
at org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseInterceptorChain.java:272)
at org.apache.cxf.endpoint.ClientImpl.doInvoke(ClientImpl.java:565)
at org.apache.cxf.endpoint.ClientImpl.invoke(ClientImpl.java:474)
at org.apache.cxf.endpoint.ClientImpl.invoke(ClientImpl.java:377)
at org.apache.cxf.endpoint.ClientImpl.invoke(ClientImpl.java:330)
at org.apache.cxf.frontend.ClientProxy.invokeSync(ClientProxy.java:96)
at org.apache.cxf.jaxws.JaxWsClientProxy.invoke(JaxWsClientProxy.java:135)
at $Proxy1106.doServiceWS(Unknown Source)
at fr.edu.rennes.cyclades.pilotage.async.WSJob.executeTask(WSJob.java:116)
at fr.edu.ac_rennes.webfusion.quartz.job.BaseJob.executeInternal(BaseJob.java:101)
at org.springframework.scheduling.quartz.QuartzJobBean.execute(QuartzJobBean.java:113)
at org.quartz.core.JobRunShell.run(JobRunShell.java:213)
at org.quartz.simpl.SimpleThreadPool$WorkerThread.run(SimpleThreadPool.java:557)有效负载:
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
<soap:Header>
<Action xmlns="http://www.w3.org/2005/08/addressing">http://api.service.support.cyclades.rennes.edu.fr/QuartzWebService/doServiceWS</Action>
<MessageID xmlns="http://www.w3.org/2005/08/addressing">urn:uuid:34978730-9686-40ec-8e66-dcc68c0be27c</MessageID>
<To xmlns="http://www.w3.org/2005/08/addressing">http://sapdcy1.in.ac-rennes.fr:8280/ws_centre/cxf/DeclarerCentresBatchService</To>
<ReplyTo xmlns="http://www.w3.org/2005/08/addressing">
<Address>http://www.w3.org/2005/08/addressing/anonymous</Address>
</ReplyTo>
</soap:Header>
<soap:Body/>
</soap:Envelope>有谁有线索吗?
发布于 2014-09-23 21:34:17
我找到了解决我的问题的办法。我将decoupled_endpoint设置为相对URL (不是以http://..开头。)因此,CXF决定使用ServletDestinationFactory而不是JettyDestinationFactory (查看org.apache.cxf.transport.http.HTTPTransportFactory.getDestination(EndpointInfo)).然后,我设置了一个构造绝对URL的CXF Interceptor,这样SOAP头中的replyTo地址就包含了一个有效的、可调用的HTTP地址。
public class ReplyToInterceptor extends AbstractPhaseInterceptor<Message> {
/** Le logger */
private static final Logger LOGGER = LoggerFactory.getLogger(ReplyToInterceptor.class);
/** Host name */
private String hostName;
/** Host port */
private String hostPort;
/**
* Constructeur par défaut
*/
public ReplyToInterceptor() {
super(Phase.PRE_LOGICAL);
addAfter(MAPAggregator.class.getName());
}
/**
* Ajoute l'adresse de retour asynchrone
* @param message Le message
*/
public void handleMessage(Message message) {
if (message instanceof XMLMessage) {
LOGGER.debug("Ignoring REST message");
return;
}
AddressingProperties maps = ContextUtils.retrieveMAPs(message, false, true, false);
if (maps != null) {
LOGGER.debug("WS-Addressing is enabled");
if (!ContextUtils.isRequestor(message)) {
LOGGER.debug("Ignoring response message");
return;
}
EndpointReferenceType replyTo = maps.getReplyTo();
if (replyTo == null) {
return;
}
AttributedURIType replyToAddress = replyTo.getAddress();
if (replyToAddress.getValue().startsWith("http") && !replyToAddress.getValue().startsWith("http://www.w3.org/2005/08/addressing/")) {
LOGGER.debug("Address is already absolute: {}", replyToAddress.getValue());
return;
}
RequestAttributes currentRequestAttributes = RequestContextHolder.getRequestAttributes();
String contextPath = null;
if (currentRequestAttributes != null) {
LOGGER.debug("HttpServletRequest is accessible");
contextPath = ((ServletRequestAttributes) currentRequestAttributes).getRequest().getContextPath();
} else {
LOGGER.debug("Can't access HttpServletRequest, replyTo address will use default context path");
contextPath = "/a_server";
}
String url = "http://" + this.hostName + ":" + this.hostPort + contextPath + "/cxf/async_endpoint";
LOGGER.debug("Setting replyTo URL to: {}", url);
replyToAddress.setValue(url);
} else {
LOGGER.debug("WS-Addressing is disabled");
}
}
}https://stackoverflow.com/questions/23884206
复制相似问题