Announcement Announcement Module
Collapse
No announcement yet.
Unmarshalling SOAPHeader Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Unmarshalling SOAPHeader

    Hi!

    I am implementing a webservice that gets security related data in the SOAPHeader.
    I use JAXB as my marshaller.

    The request payload gets unmarshalled fine, but I have no idea how to tell SpringWS to also unmarshall the SoapHeader.

    This is my handler method:

    Code:
    @PayloadRoot(localPart = "LeistungsdatenUebermittlung", namespace = "http://transparenzportal.gv.at/leistungsdaten")
        @ResponsePayload
    	 public VerarbeitungsprotokollType uebermittlung(@RequestPayload LeistungsdatenUebermittlungType leistungsdaten, @SoapHeader(value="{http://egov.gv.at/pvp1.xsd}pvpToken") PVPToken pvpToken) throws Exception {
    ...
    }
    My SOAPRequest looks like this:

    Code:
    <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:pvp1="http://egov.gv.at/pvp1.xsd" xmlns:leis="http://transparenzportal.gv.at/leistungsdaten" xmlns:per="http://reference.e-government.gv.at/persondata" xmlns:xd="http://www.w3.org/2000/09/xmldsig#">
       <soapenv:Header>
          <pvp1:pvpToken>
              ....
          </pvp1:pvpToken>
       </soapenv:Header>
       <soapenv:Body>
          <leis:LeistungsdatenUebermittlung>
             ....
          </leis:LeistungsdatenUebermittlung>
       </soapenv:Body>
    </soapenv:Envelope>
    The JAXB-generated classes are correct, they already work with this xml in another context.

    When I send the request, I get the error message:
    No adapter for endpoint ... ... ...

    The only way to get it working is to change the method to:

    Code:
    @PayloadRoot(localPart = "LeistungsdatenUebermittlung", namespace = "http://transparenzportal.gv.at/leistungsdaten")
        @ResponsePayload
    	 public VerarbeitungsprotokollType uebermittlung(@RequestPayload LeistungsdatenUebermittlungType leistungsdaten, SoapHeader soapHeader) throws Exception {
    ...
       Iterator<SoapHeaderElement> it = soapHeader.examineAllHeaderElements();
       while(it.hasNext()) {
    	SoapHeaderElement e = it.next();
    	JAXBContext jc = JAXBContext.newInstance("at.gv.e_government.pvp");
    	Unmarshaller um = jc.createUnmarshaller();
    	PvpToken token = (PvpToken)um.unmarshal(e.getSource());
       }
    ...
    }
    So, I only get the element and have to do the unmarshalling by hand.

    While this works fine I don't understand why Spring will unmarshall the payload, but not the SOAPHeader.

    Am I using the @SoapHeader - annotation wrong?

    Kind Regards,
    Andreas

  • #2
    Same issue with XmlBeans

    I have the exact same problem :-

    @PayloadRoot(namespace = "...", localPart = "...")
    public MyResponseDocument process(MyRequestDocument request, SoapHeader header) throws Exception {
    ...
    }

    If I drop the header attribute it works fine but otherwise I get "No adapter for endpoint"

    At startup I see the method be picked up as the target for the namespace/localpart :-

    2012-02-16T14:49:03,144 | main | MsgId:[] | DEBUG | org.springframework.ws.server.endpoint.mapping.Pay loadRootAnnotationMethodEndpointMapping Mapped [{http://...}...] onto endpoint [public MyResponseDocument MyEndpoint.process(MyRequestDocument,org.springfra mework.ws.soap.SoapHeader) throws Exception

    This is using Spring-WS 2.0.4

    Comment


    • #3
      thanks for informative post

      Comment


      • #4
        Could you post your marshalling configuration? Having the same issue, but then with the body itself.
        cheers

        Comment


        • #5
          Originally posted by vonbrittelstrausse View Post
          Could you post your marshalling configuration? Having the same issue, but then with the body itself.
          cheers
          Sorry, I don't really know what you ask me to post. I just use jaxb to marshall und unmarshall:

          Code:
          <bean id="jaxb2MarshallerLeistungsdaten" class="org.springframework.oxm.jaxb.Jaxb2Marshaller">
                  <property name="classesToBeBound">
                      <list>
                          <value>at.gv.bmf.tradaba.domain.leistungsdaten.jaxb.LeistungsdatenUebermittlung</value>
                          <value>at.gv.bmf.tradaba.domain.leistungsdaten.jaxb.LeistungsdatenResponse</value>
                      </list>
                  </property>
          </bean>
          If you get the "No adapter for endpoint ..." message, check if your bean is annotated with @XmlRootElement.
          If it is missing, you get this error.

          You can add the annotation by hand, or trick the jaxb compiler into adding it by using a custom binding file and adding:

          Code:
          <globalBindings>
                 <xjc:simple/>
          </globalBindings>
          Hope this helps!

          Comment

          Working...
          X