当前位置 : 主页 > 编程语言 > java >

从Spring WS Interceptor获取Request参数(Getting Request parameters from Spring WS Interceptor)

来源:互联网 收集:自由互联 发布时间:2022-10-26
I am using Jaxb 2 with a Spring WS, and I have an interceptor which is directed to a particular payload and it works fine. Here my requirement is to read the request parameters from the handleRequest method of my interceptor. I know this sh


  I am using Jaxb 2 with a Spring WS, and I have an interceptor which is directed to a particular payload and it works fine.

  Here my requirement is to read the request parameters from the handleRequest method of my interceptor. I know this should be fairly straight forward. However could not figure out a way to read the request parameters. At the moment my handleRequest method looks as below.

@Override
  public boolean handleRequest(MessageContext messageContext, Object endpoint)
  throws Exception {
  boolean proceed=true;
  SaajSoapMessage saajSoapMessage= (SaajSoapMessage) messageContext.getRequest();
  SOAPMessage soapMessage=saajSoapMessage.getSaajMessage();
  Document doc=saajSoapMessage.getDocument();
  Element element=doc.getElementById("request");
  }
  The relevant part of the my Endpoint class is
  @PayloadRoot(namespace=NAMESPACE, localPart="confirOrderRequest")
  public @ResponsePayload ConfirmOrderResponse handleConfirmOrder(
  @RequestPayload ConfirmOrderRequest confirmOrderRequest) {
  ...........
  }

  Here my requirement is to get the orderId which comes with the ConfirmOrderRequest in the interceptor handleRequest method, is there a way to do this directly, or do I need to do some XML parsing for that?

  盾畳圭宛

  @VitualTroll, It helped me somewhat, thanks !

  But answer on that question is incorrect(at least in my case). Body of my new handleRequest() method would looks as follows. Hope this would save some time for someone else in future. Here jaxb2Marshaller is my spring bean.

 

@Autowired
  private Jaxb2Marshaller jaxb2Marshaller;
  @Override
  public boolean handleRequest(MessageContext messageContext, Object endpoint) throws Exception {
  boolean proceed=true;
  SaajSoapMessage saajSoapMessage=(SaajSoapMessage) messageContext.getRequest();
  SoapBody requestBody=saajSoapMessage.getSoapBody();
  Object obj=jaxb2Marshaller.unmarshal(requestBody.getPayloadSource());
  if (obj instanceof ConfirmOrderRequest ) {
  ConfirmOrderRequest cor=(ConfirmOrderRequest ) obj;
  String orderId=cor.getOrderId();
  ...........
  .......
  }
  .....
  } 【本文来源:武汉网站优化 http://www.5h5q.com网络转载请说明出处】
上一篇:后台request接收ajax传输的参数
下一篇:没有了
网友评论