2016-03-28 83 views
0

我的公司订阅了旅行预订系统提供的服务,当旅行行程发生任何变化时,他们会给我们回电。我的任务是站出一个SOAP端点来接受这个回调。我正在用标准的jax-ws来做这件事。实施SOAP Web服务:处理复杂对象参数

这里是他们SOAP消息的要领:

<soap-env:Envelope xmlns:soap-env="http://schemas.xmlsoap.org/soap/envelope/" 
xmlns:eb="http://www.ebxml.org/namespaces/messageHeader" xmlns:swse="http://wse.sabre.com/eventing" 
xmlns:wsa="http://schemas.xmlsoap.org/ws/2004/08/addressing" xmlns:wse="http://schemas.xmlsoap.org/ws/2004/08/eventing"> 
<soap-env:Header> 
    <eb:MessageHeader eb:version="1.0" 
     soap-env:mustUnderstand="1"> 
     <wse:MySubscription>7TZA</wse:MySubscription> 
     <swse:EventTopic>WSE.QUEUE.CCC.PNRCHNG</swse:EventTopic> 
    </eb:MessageHeader> 
    <wsa:Action>http://wse.sabre.com/EventSource/notification</wsa:Action> 
    <wsa:MessageID>721d8dc0-1307-4b27-a48b-a9ba7f7818c7</wsa:MessageID> 
    <wse:Identifer>7f9aad13-a8cd-4057-8c91-89ccfad64598</wse:Identifer> 
    <wsa:To>http://localhost:18888/</wsa:To> 
</soap-env:Header> 
<soap-env:Body> 
    <swse:CCC.PNRCHNG> 
     <swse:OWNPCC>N0V3</swse:OWNPCC> 
     <swse:HOMEPCC>W0H3</swse:HOMEPCC> 
     <swse:Locator>IGLYIZ</swse:Locator> 
     <swse:EventTimeStamp format="yyyy-MM-dd hh:mm:ss.fffffffff">2007-10-30 11:41:32.000986</swse:EventTimeStamp> 
     <swse:ChangeIndicators> 
      <swse:Indicator name="Ticketing"> 
       <swse:hasChanged>Y</swse:hasChanged> 
      </swse:Indicator> 
      ... 
    </swse:CCC.PNRCHNG> 
</soap-env:Body> 

我有一个getHeaders一个正常运作SOAPHandler()实现至极被满足的mustUnderstand = 1的要求。

我有一个@WebMethod,它成功地接受了一些有效负载的顶级部分。这实际上已经够好了,但我想了解如何编写一个@Webmethod来接受整个有效负载作为一个复杂的对象。

我有一个jibx生成的CCC.PNRCHNG类。但是,我将如何编写@WebMethod来接受它?下面是接受顶层位为独立的@WebParams方法(定位器是我真正需要的现在)

@WebMethod(operationName="CCC.PNRCHNG", action="http://wse.sabre.com/EventSource/notification") 
public Object onPnrEvent(
     @WebParam(name="OWNPCC", targetNamespace=NS) String ownPcc, 
     @WebParam(name="HOMEPCC", targetNamespace=NS) String homePcc, 
     @WebParam(name="Locator", targetNamespace=NS) String locator 
     ) { 
    try { 
     s_logger.info(locator); 
    } 
    catch(Exception e) { 
     s_logger.error(e); 
    } 
    return null; 
} 

这将是很好得到充分的模式,使任何建议会有非常感激。

+0

你有这个回调接口的WSDL吗?如果是这样,您可以使用'wsimport'来生成一个服务提供者,包括一个接受完整复杂类型对象模型输入参数的@ WebMethod。 –

回答

0

最好的方法是使用wsimport生成基于WSDL的PortType。如果您没有WSDL,那么我不会为编写一个包装的JAX-WS服务而烦恼。

在您的类中,添加此注释

@SOAPBinding(parameterStyle = SOAPBinding.ParameterStyle.BARE) 

然后写接受根元素的方法。类似这样的:

@WebMethod(operationName="CCC.PNRCHNG", action="http://wse.sabre.com/EventSource/notification") 
public Object onPnrEvent(@WebParam(name="CCC.PNRCHNG", targetNamespace=NS) PNRCHNG request) { 

}