简体   繁体   中英

Problems with handling incoming SOAP message

I am trying to define a SOAP service that consumes OASIS WS-N notification messages.

I do 'WSDL-to-Java' approach but for some reason the incoming message is not being recognized.

Relevant fragments from WSDL:

<wsdl:definitions name="WSNBrokerNotification"
    targetNamespace="http://docs.oasis-open.org/wsn/brw-2"
    xmlns:tns="http://docs.oasis-open.org/wsn/brw-2"
    xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
    xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
    xmlns:wsntw="http://docs.oasis-open.org/wsn/bw-2"
    xmlns:wsnt="http://docs.oasis-open.org/wsn/b-2"
    xmlns:wsa="http://www.w3.org/2005/08/addressing"
    xmlns:wsrf-rw="http://docs.oasis-open.org/wsrf/rw-2"
    xmlns:xsd="http://www.w3.org/2001/XMLSchema"
    xmlns:wsn-br="http://docs.oasis-open.org/wsn/br-2"
    xmlns:wstop="http://docs.oasis-open.org/wsn/t-1"
    xmlns:wsn-brw="http://docs.oasis-open.org/wsn/brw-2">

...

  <wsdl:message name="Notify">
    <wsdl:part name="Notify" element="wsnt:Notify"/>
  </wsdl:message>

...

<!-- ========= NotificationConsumer PortType Definition =========== -->
  <wsdl:portType name="NotificationConsumer">
    <wsdl:operation name="Notify">
      <wsdl:input message="tns:Notify"/>
    </wsdl:operation>
  </wsdl:portType>

...

<!-- ========= NotificationConsumer PortType Definition =========== -->
  <wsdl:portType name="NotificationConsumer">
    <wsdl:operation name="Notify">
      <wsdl:input message="tns:Notify"/>
    </wsdl:operation>
  </wsdl:portType>

...

 <wsdl:binding name="NotificationConsumer" type="tns:NotificationConsumer">
    <soap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"/>
    <wsdl:operation name="Notify">
      <soap:operation soapAction="http://docs.oasis-open.org/wsn/bw-2/NotificationConsumer/Notify"/>
      <wsdl:input>
        <soap:body use="literal"/>
      </wsdl:input>
    </wsdl:operation>
  </wsdl:binding>

...

<!-- =============== SERVICE ================= -->

  <wsdl:service name="WSNBrokerNotification">
     ....

     <wsdl:port name="NotificationConsumer" binding="tns:NotificationConsumer">
       <soap:address location="http://localhost:19001"/>
     </wsdl:port>
...

  </wsdl:service>

</wsdl:definitions>

When the following SOAP message is arriving:

<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/" xmlns:a="http://www.w3.org/2005/08/addressing">
  <s:Header>
    <a:Action s:mustUnderstand="1">http://docs.oasis-open.org/wsn/bw-2/NotificationConsumer/Notify</a:Action>
    <a:To s:mustUnderstand="1">http://jenkins.nu.majiic:50918/spsconsumerTest_f4bcbd26-8e96-45fe-b622-563d0e4a8edf</a:To>
  </s:Header>
  <s:Body xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
    <Notify xmlns="http://docs.oasis-open.org/wsn/b-2">
      <NotificationMessage>
        <MyLittleMessage/>
      </NotificationMessage>
    </Notify>
  </s:Body>
</s:Envelope>

my SOAP framework - Apache CXF - reports this:

[qtp558404860-18] WARN org.apache.cxf.phase.PhaseInterceptorChain - Interceptor for {http://consumer.wsn.foo.bar/}WSBrokerNotificationConsumerService has thrown exception, unwinding now
org.apache.cxf.interceptor.Fault: Message part {http://docs.oasis-open.org/wsn/b-2}Notify was not recognized.  (Does it exist in service WSDL?)
    at org.apache.cxf.wsdl.interceptors.DocLiteralInInterceptor.validatePart(DocLiteralInInterceptor.java:252)
    at org.apache.cxf.wsdl.interceptors.DocLiteralInInterceptor.handleMessage(DocLiteralInInterceptor.java:191)
    at org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseInterceptorChain.java:308)
    at org.apache.cxf.transport.ChainInitiationObserver.onMessage(ChainInitiationObserver.java:121)
    at org.apache.cxf.transport.http.AbstractHTTPDestination.invoke(AbstractHTTPDestination.java:267)
    at org.apache.cxf.transport.http_jetty.JettyHTTPDestination.doService(JettyHTTPDestination.java:247)
    at org.apache.cxf.transport.http_jetty.JettyHTTPHandler.handle(JettyHTTPHandler.java:79)
    at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:127)
    at org.eclipse.jetty.server.handler.ScopedHandler.nextHandle(ScopedHandler.java:235)
    at org.eclipse.jetty.server.handler.ContextHandler.doHandle(ContextHandler.java:1300)
    at org.eclipse.jetty.server.handler.ScopedHandler.nextScope(ScopedHandler.java:190)
    at org.eclipse.jetty.server.handler.ContextHandler.doScope(ContextHandler.java:1215)
    at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:141)
    at org.eclipse.jetty.server.handler.ContextHandlerCollection.handle(ContextHandlerCollection.java:221)
    at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:127)
    at org.eclipse.jetty.server.Server.handle(Server.java:500)
    at org.eclipse.jetty.server.HttpChannel.lambda$handle$1(HttpChannel.java:383)
    at org.eclipse.jetty.server.HttpChannel.dispatch(HttpChannel.java:547)
    at org.eclipse.jetty.server.HttpChannel.handle(HttpChannel.java:375)
    at org.eclipse.jetty.server.HttpConnection.onFillable(HttpConnection.java:273)
    at org.eclipse.jetty.io.AbstractConnection$ReadCallback.succeeded(AbstractConnection.java:311)
    at org.eclipse.jetty.io.FillInterest.fillable(FillInterest.java:103)
    at org.eclipse.jetty.io.ChannelEndPoint$2.run(ChannelEndPoint.java:117)
    at org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:806)
    at org.eclipse.jetty.util.thread.QueuedThreadPool$Runner.run(QueuedThreadPool.java:938)
    at java.lang.Thread.run(Thread.java:748)
[qtp558404860-18] INFO org.apache.cxf.services.WSBrokerNotificationConsumerService.WSBrokerNotificationConsumerPort.WSBrokerNotificationConsumer - Outbound Message

I am a bit confused, because I can clearly definition of <Notify> elements with proper namespace, unless I am missing something?...

Any help will be greatly appreciated!

solved; the issue was due to the lack of @WebService annotation on the class that was implementing the web service.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM