0 Replies Latest reply on Jul 29, 2009 1:09 PM by kay devy

    Username token: Problem accessing the soap message. Empty he

    kay devy Newbie

      Hi All,

      on using username profile with the POJO endpoint i realized that the saop header in the POJO was empty (no child elements).
      I could confirm this on debugging the SOAPMessage in the POJO.
      I need the username within the POJO for further authorization checks.
      The simple HelloWorld WebService as well as authentication and authorisation (JAAS) are working fine, but as i said, no child elements in the soap header.

      I used:
      JBoss 4.2.3.GA
      jbossws-native-3.1.1.GA

      And

      JBoss 5.1.0.GA
      jbossws-native-3.1.2.GA

      No success!

      The sent mesage from the client using soapui is:

      <env:Envelope xmlns:env='http://schemas.xmlsoap.org/soap/envelope/'>
       <env:Header>
       <wsse:Security env:mustUnderstand='1' xmlns:wsse='http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd' xmlns:wsu='http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd'>
       <wsse:UsernameToken wsu:Id='token-1-1248789148312-14111765'>
       <wsse:Username>kermit</wsse:Username>
       <wsse:Password Type='http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-username-token-profile-1.0#PasswordText'>thefrog</wsse:Password>
       </wsse:UsernameToken>
       </wsse:Security>
       </env:Header>
       <env:Body>
       <ns1:sayHello xmlns:ns1='org.jbia.ws'>
       <arg0>World</arg0>
       </ns1:sayHello>
       </env:Body>
      </env:Envelope>
      


      This is the same message that has been traced in the server log. So, the message ist ok. Furthermore authorisation and authentication are working.

      I tried to get the header child elements in the following ways:

      1)
       SOAPMessageContext soapMessageContext = (SOAPMessageContext)wsCtx.getMessageContext();
       SOAPMessage message = soapMessageContext.getMessage();
       try {
       Iterator it = message.getSOAPHeader().getChildElements();
       while(it.hasNext()){
       System.out.println("The child: " + it.next().toString());
       }
       } catch (SOAPException e) {
       // TODO Auto-generated catch block
       e.printStackTrace();
       }
      


      2)
       CommonMessageContext msgContext = MessageContextAssociation.peekMessageContext();
       try {
       SOAPHeader header = msgContext.getSOAPMessage().getSOAPHeader();
       Iterator it = header.getChildElements();
       while(it.hasNext()){
       System.out.println("The child: " + it.next().toString());
       }
       } catch (SOAPException e) {
       // TODO Auto-generated catch block
       e.printStackTrace();
       }
      


      3)
       SOAPEnvelope envelope;
       try {
       envelope = soapMessageContext.getMessage().getSOAPPart().getEnvelope();
       SOAPHeader soapHeader = envelope.getHeader();
       Iterator it = soapHeader.getChildElements();
       while(it.hasNext()){
       Object o = it.next();
       System.out.println("The Child: " + o.toString());
       }
       } catch (SOAPException e) {
       // TODO Auto-generated catch block
       e.printStackTrace();
       }
      


      I even tried to get the principal:

       Principal principal = wsCtx.getUserPrincipal();
       if (principal==null){
       System.out.println("There is no principal name");
       } else {
       System.out.println("The principal name is " + principal.getName());
       }
      


      But no success!

      Am i missing something? is there another way to handel this issue? is there any workarround for this? wrong version of jboss and jbossws-native?

      I apreciate very gratefully any suggestion.

      Thank's