mule - How to set Webservice Client with WS Security -
i have webservice ws security next :-
<!-- authentication security--> <mule-ss:security-manager> <mule-ss:delegate-security-provider name="memory-provider" delegate-ref="authenticationmanager" /> </mule-ss:security-manager> <spring:beans> <ss:authentication-manager alias="authenticationmanager"> <ss:authentication-provider> <ss:user-service id="userservice"> <ss:user name="${username1}" password="${password1}" authorities="role_admin" /> </ss:user-service> </ss:authentication-provider> </ss:authentication-manager> </spring:beans> <cxf:ws-security name="inboundsecurityconfig"> <cxf:mule-security-manager /> <!-- reading username , password spring beans --> <cxf:ws-config> <cxf:property key="action" value="usernametoken" /> </cxf:ws-config> </cxf:ws-security> <!-- authentication security ends--> <flow name="securedbrewsoapservice"> <http:inbound-endpoint exchange-pattern="request-response" host="localhost" port="8090" path="designation" doc:name="http"> <cxf:jaxws-service serviceclass="com.getdesignation.test.services.schema.maindata.v1.getdesignation"> <cxf:ws-security ref="inboundsecurityconfig"/> </cxf:jaxws-service> </http:inbound-endpoint> <component class="com.getdesignation.test.services.schema.maindata.v1.impl.getdesignationimpl" /> </flow>
now works fine .. issue client :-
<flow name="securityclientflow2" doc:name="securityclientflow2"> <http:inbound-endpoint doc:name="http inbound endpoint" exchange-pattern="request-response" host="localhost" path="client" port="63080"/> <set-payload doc:name="set payload" value="#[import com.getdesignation.test.services.schema.maindata.v1.*; drequest = new designationrequest();drequest.designationcode = ${code};drequest]"/> <cxf:jaxws-client doc:name="soap" serviceclass="com.getdesignation.test.services.schema.maindata.v1.getdesignation" operation="getdesignationvalue" port="getdesignationport" > <cxf:ws-security ref="inboundsecurityconfig"/> </cxf:jaxws-client> <http:outbound-endpoint exchange-pattern="request-response" host="localhost" port="8090" path="designation" doc:name="http"/> <mulexml:object-to-xml-transformer doc:name="object xml"/> <logger message="#[system.getproperty('line.separator')+message.payload]" level="info" doc:name="json logging"/> <set-payload doc:name="set payload" value="#[message.payload]"/> </flow>
it gives next exception :-
warn 2014-10-18 00:40:05,534 [[soapsecurity2].connector.http.mule.default.receiver.03] org.apache.cxf.phase.phaseinterceptorchain: interceptor {http://services.test.getdesignation.com/schema/maindata/v1}getdesignationservice#{http://services.test.getdesignation.com/schema/maindata/v1}getdesignationvalue has thrown exception, unwinding org.apache.cxf.binding.soap.soapfault: empty username specified action. @ org.apache.cxf.ws.security.wss4j.wss4joutinterceptor$wss4joutinterceptorinternal.handlemessage(wss4joutinterceptor.java:226) @ org.apache.cxf.ws.security.wss4j.wss4joutinterceptor$wss4joutinterceptorinternal.handlemessage(wss4joutinterceptor.java:136) @ org.apache.cxf.phase.phaseinterceptorchain.dointercept(phaseinterceptorchain.java:263) @ org.mule.module.cxf.transport.muleuniversalconduit$1.write(muleuniversalconduit.java:143) @ org.mule.transport.http.streampayloadrequestentity.writerequest(streampayloadrequestentity.java:35) @ org.apache.commons.httpclient.methods.entityenclosingmethod.writerequestbody(entityenclosingmethod.java:499) @ org.apache.commons.httpclient.httpmethodbase.writerequest(httpmethodbase.java:2114) @ org.apache.commons.httpclient.httpmethodbase.execute(httpmethodbase.java:1096) @ org.apache.commons.httpclient.httpmethoddirector.executewithretry(httpmethoddirector.java:398) @ org.apache.commons.httpclient.httpmethoddirector.executemethod(httpmethoddirector.java:171) @ org.apache.commons.httpclient.httpclient.executemethod(httpclient.java:397) @ org.apache.commons.httpclient.httpclient.executemethod(httpclient.java:346) @ org.mule.transport.http.httpclientmessagedispatcher.execute(httpclientmessagedispatcher.java:144) @ org.mule.transport.http.httpclientmessagedispatcher.dosend(httpclientmessagedispatcher.java:279) @ org.mule.transport.abstractmessagedispatcher.process(abstractmessagedispatcher.java:84) @ org.mule.transport.abstractconnector$dispatchermessageprocessor.process(abstractconnector.java:2636) @ org.mule.execution.exceptiontomessagingexceptionexecutioninterceptor.execute(exceptiontomessagingexceptionexecutioninterceptor.java:24) @ org.mule.execution.messageprocessornotificationexecutioninterceptor.execute(messageprocessornotificationexecutioninterceptor.java:58) @ org.mule.execution.messageprocessorexecutiontemplate.execute(messageprocessorexecutiontemplate.java:44) @ org.mule.processor.abstractinterceptingmessageprocessorbase.processnext(abstractinterceptingmessageprocessorbase.java:102) @ org.mule.module.cxf.cxfoutboundmessageprocessor.processnext(cxfoutboundmessageprocessor.java:160) @ org.mule.module.cxf.transport.muleuniversalconduit.processnext(muleuniversalconduit.java:345) @ org.mule.module.cxf.transport.muleuniversalconduit.dispatchmulemessage(muleuniversalconduit.java:248) @ org.mule.module.cxf.transport.muleuniversalconduit$2.handlemessage(muleuniversalconduit.java:190) @ org.apache.cxf.phase.phaseinterceptorchain.dointercept(phaseinterceptorchain.java:263) @ org.apache.cxf.endpoint.clientimpl.doinvoke(clientimpl.java:531) @ org.apache.cxf.endpoint.clientimpl.invoke(clientimpl.java:462) @ org.mule.module.cxf.cxfoutboundmessageprocessor.dosendwithclient(cxfoutboundmessageprocessor.java:236) @ org.mule.module.cxf.cxfoutboundmessageprocessor.process(cxfoutboundmessageprocessor.java:123) @ org.mule.execution.exceptiontomessagingexceptionexecutioninterceptor.execute(exceptiontomessagingexceptionexecutioninterceptor.java:24) @ org.mule.execution.messageprocessornotificationexecutioninterceptor.execute(messageprocessornotificationexecutioninterceptor.java:58) @ org.mule.execution.messageprocessorexecutiontemplate.execute(messageprocessorexecutiontemplate.java:44) @ org.mule.processor.chain.simplemessageprocessorchain.doprocess(simplemessageprocessorchain.java:43) @ org.mule.processor.chain.abstractmessageprocessorchain.process(abstractmessageprocessorchain.java:67) @ org.mule.execution.exceptiontomessagingexceptionexecutioninterceptor.execute(exceptiontomessagingexceptionexecutioninterceptor.java:24) @ org.mule.execution.messageprocessorexecutiontemplate.execute(messageprocessorexecutiontemplate.java:44) @ org.mule.processor.abstractinterceptingmessageprocessorbase.processnext(abstractinterceptingmessageprocessorbase.java:102) @ org.mule.endpoint.outbound.outboundresponsepropertiesmessageprocessor.process(outboundresponsepropertiesmessageprocessor.java:35) @ org.mule.execution.exceptiontomessagingexceptionexecutioninterceptor.execute(exceptiontomessagingexceptionexecutioninterceptor.java:24) @ org.mule.execution.messageprocessornotificationexecutioninterceptor.execute(messageprocessornotificationexecutioninterceptor.java:58) @ org.mule.execution.messageprocessorexecutiontemplate.execute(messageprocessorexecutiontemplate.java:44) @ org.mule.processor.chain.simplemessageprocessorchain.doprocess(simplemessageprocessorchain.java:43) @ org.mule.processor.chain.abstractmessageprocessorchain.process(abstractmessageprocessorchain.java:67) @ org.mule.execution.exceptiontomessagingexceptionexecutioninterceptor.execute(exceptiontomessagingexceptionexecutioninterceptor.java:24) @ org.mule.execution.messageprocessorexecutiontemplate.execute(messageprocessorexecutiontemplate.java:44) caused by: com.ctc.wstx.exc.wstxeofexception: unexpected eof in prolog @ [row,col {unknown-source}]: [1,0] @ com.ctc.wstx.sr.streamscanner.throwunexpectedeof(streamscanner.java:677) @ com.ctc.wstx.sr.basicstreamreader.handleeof(basicstreamreader.java:2116) @ com.ctc.wstx.sr.basicstreamreader.nextfromprolog(basicstreamreader.java:2022) @ com.ctc.wstx.sr.basicstreamreader.next(basicstreamreader.java:1114) @ com.ctc.wstx.sr.basicstreamreader.nexttag(basicstreamreader.java:1137) @ org.apache.cxf.binding.soap.saaj.saajininterceptor$saajpreininterceptor.handlemessage(saajininterceptor.java:125) ... 54 more info 2014-10-18 00:40:05,725 [[soapsecurity2].connector.http.mule.default.receiver.03] org.mule.transport.http.httpclientmessagedispatcher: received redirect, followredirects=false. response code: 500 internal server error error 2014-10-18 00:40:05,745 [[soapsecurity2].connector.http.mule.default.receiver.03] org.mule.exception.defaultmessagingexceptionstrategy: ******************************************************************************** message : empty username specified action.. failed route event via endpoint: org.mule.module.cxf.cxfoutboundmessageprocessor. message payload of type: postmethod code : mule_error--2 -------------------------------------------------------------------------------- exception stack is: 1. empty username specified action. (org.apache.cxf.binding.soap.soapfault) org.apache.cxf.ws.security.wss4j.wss4joutinterceptor$wss4joutinterceptorinternal:226 (null) 2. empty username specified action.. failed route event via endpoint: org.mule.module.cxf.cxfoutboundmessageprocessor. message payload of type: postmethod (org.mule.api.transport.dispatchexception) org.mule.module.cxf.cxfoutboundmessageprocessor:142 (http://www.mulesoft.org/docs/site/current3/apidocs/org/mule/api/transport/dispatchexception.html) -------------------------------------------------------------------------------- root exception stack trace: org.apache.cxf.binding.soap.soapfault: empty username specified action. @ org.apache.cxf.ws.security.wss4j.wss4joutinterceptor$wss4joutinterceptorinternal.handlemessage(wss4joutinterceptor.java:226) @ org.apache.cxf.ws.security.wss4j.wss4joutinterceptor$wss4joutinterceptorinternal.handlemessage(wss4joutinterceptor.java:136) @ org.apache.cxf.phase.phaseinterceptorchain.dointercept(phaseinterceptorchain.java:263) + 3 more (set debug level logging or '-dmule.verbose.exceptions=true' everything) ********************************************************************************
please help .. how set client ws security
use next cxf:ws-config part of security in cxf:jaxws-client
<cxf:ws-security> <cxf:ws-config> <cxf:property key="action" value="usernametoken" /> <cxf:property key="passwordtype" value="passwordtext" /> <cxf:property key="user" value="${username}" /> <cxf:property key="passwordcallbackclass" value="client.clientpasswordcallback" /> </cxf:ws-config> </cxf:ws-security>
and password callback should class
public class clientpasswordcallback implements callbackhandler { public void handle(callback[] callbacks) throws ioexception, unsupportedcallbackexception { wspasswordcallback pc = (wspasswordcallback) callbacks[0]; if ("sampleusername".equals(pc.getidentifier())) { pc.setpassword("samplepassword"); } } }
hope helps.
mule mule-studio
No comments:
Post a Comment