web services - SOAP UI Generated JAVA client throwing MustUnderstandHeaders are not understood error -


this first post here please patient. have wsdl , used soap ui generate java client. plugged in client test project , using client access web service. web service expects security headers(which not part of wsdl policy) had use handlers in order add security headers soap envelope created. on running program throws following error... when run same soap request via soap ui seems process fine. interesting thing noticed although run same request(including nonce of security header) in soap ui after processing in client (after error thrown) still seems process fine. when try , run same request in soap ui twice throws exception along lines of not being able use same nonce value more once (this expected behavior). makes me think error being generated after running client not reaching server running web service otherwise nonce have been cached there , wouldn't able run in soap ui. have attached handler class method below error block. inclined believe security header fine since message processes fine in soap ui. appreciated.

javax.xml.ws.soap.soapfaultexception: mustunderstand headers:[{http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd}security] not understood @ com.sun.xml.internal.ws.protocol.soap.mutube.createmusoapfaultexception(unknown source) @ com.sun.xml.internal.ws.protocol.soap.clientmutube.processresponse(unknown source) @ com.sun.xml.internal.ws.api.pipe.fiber.__dorun(unknown source) @ com.sun.xml.internal.ws.api.pipe.fiber._dorun(unknown source) @ com.sun.xml.internal.ws.api.pipe.fiber.dorun(unknown source) @ com.sun.xml.internal.ws.api.pipe.fiber.runsync(unknown source) @ com.sun.xml.internal.ws.client.stub.process(unknown source) @ com.sun.xml.internal.ws.client.sei.seistub.doprocess(unknown source) @ com.sun.xml.internal.ws.client.sei.syncmethodhandler.invoke(unknown source) @ com.sun.xml.internal.ws.client.sei.syncmethodhandler.invoke(unknown source) @ com.sun.xml.internal.ws.client.sei.seistub.invoke(unknown source) @ com.sun.proxy.$proxy34.searchdemographics(unknown source) @ com.douglas.client.client.main(client.java:50)

public boolean handlemessage(soapmessagecontext smc) {

    boolean outboundproperty = (boolean) smc.get(messagecontext.message_outbound_property);      if (outboundproperty.booleanvalue()) {          soapmessage message = smc.getmessage();           try {              //message.writeto(system.out);              //system.out.println("\n");             string nonce = getnonce();             string password1 = "password01";             simpledateformat ft = new simpledateformat("yyyy-mm-dd't'hh:mm:ss'z'");             string messagecrtime = ft.format(new date());             string passworddigest = shasum(nonce, password1, messagecrtime);              soapenvelope envelope = smc.getmessage().getsoappart().getenvelope();             soapheader header = envelope.addheader();              soapelement security =                     header.addchildelement("security", "wsse", "http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd");              soapelement usernametoken =                     security.addchildelement("usernametoken", "wsse");             usernametoken.addattribute(new qname("xmlns:wsu"), "http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd");              soapelement username =                     usernametoken.addchildelement("username", "wsse");             username.addtextnode("username");              soapelement password =                     usernametoken.addchildelement("password", "wsse");             password.setattribute("type", "http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-username-token-profile-1.0#passworddigest");            password.addtextnode(passworddigest);             soapelement nonceelem =                    usernametoken.addchildelement("nonce", "wsse");            //password.setattribute("type", "http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-username-token-profile-1.0#passwordtext");            nonceelem.addtextnode(base64.encodebytes(nonce.getbytes()));             soapelement created =                    usernametoken.addchildelement("created", "wsu");            //password.setattribute("type", "http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-username-token-profile-1.0#passwordtext");            created.addtextnode(messagecrtime);              //print out outbound soap message system.out             message.writeto(system.out);             system.out.println("");          } catch (exception e) {             e.printstacktrace();         }      } else {         try {              //this handler nothing response web service             //we print out soap message.             soapmessage message = smc.getmessage();             message.writeto(system.out);             system.out.println("");          } catch (exception ex) {             ex.printstacktrace();         }      }       return outboundproperty;  } 

found out solution. reason client throwing these errors because when receives response web service mustunderstand set '1'. since wsdl policy did not include security components, client not know it. work around add following method in headerhandler.java class.

 public set getheaders() {         final qname securityheader = new qname(                   "http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd",                   "security", "wsse");            final hashset<qname> headers = new hashset<qname>();           headers.add(securityheader);           return headers;            //throw new unsupportedoperationexception("not supported yet.");     } 

Comments

Popular posts from this blog

apache - Remove .php and add trailing slash in url using htaccess not loading css -

javascript - jQuery show full size image on click -