Sorry, I don't know the CXF dynamic client so am unsure of its
configuration with respect to WS-SecurityPolicy (I try to stick with the
standard JAX-WS stuff.) But it looks like your client is not detecting
the username configuration you're providing for it.
As for the header, any header can be added via JAX-WS Headers or CXF
interceptors (http://www.jroller.com/gmazza/entry/blog_article_index,
blog entries #52 and #53) but it looks like you have an implicit header
there, so article #56 might be able to provide a very simple method for
you to add the headers in.
You might want to try accessing the service via soapUI to become certain
of the required SOAP request format. Wireshark (article #33) can be
used to check the SOAP requests that CXF is sending out on the wire.
HTH,
Glen
On 08/03/2012 01:01 PM, Aaron Stromas wrote:
In the WSDL I received I found the following
<wsdl:input>
<soap:body use="literal" />
<soap:header message="tns:StandardRequestMessage"
part="subscriptionEnforcement" use="literal" />
<wsp:PolicyReference URI="#UsernameToken" />
</wsdl:input>
<wsdl:output>
The code generated by wsdl2java has also generated an Enforcement element
which consists of two identity objects. It appears that this object needs
to be inserted into the headers (how is it done?). Is it possible that I
am getting the "user not found" error due to not having the correct SOAP
header?
Regards,
-a
On 3 August 2012 12:32, Aaron Stromas <[email protected]> wrote:
I have read and re-read it. Based on it I decided I was facing
WS-SecurityPolicy situation. Just to be sure, I did try the WSS4J
interceptors with apparently identical results. Since this is dynamic
client I don't need any configuration files, do I?
Regards,
-a
On 3 August 2012 12:09, Glen Mazza <[email protected]> wrote:
This blog entry might help: http://www.jroller.com/gmazza/**
entry/cxf_usernametoken_**profile<http://www.jroller.com/gmazza/entry/cxf_usernametoken_profile>
Regards,
Glen
On 08/03/2012 12:07 PM, Aaron Stromas wrote:
Hello,
I have received a WSDL that contains a policy element
<wsp:Policy wsu:Id="UsernameToken" xmlns:wsu="
http://docs.oasis-open.org/**wss/2004/01/oasis-200401-wss-**
wssecurity-utility-1.0.xsd<http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd>
"
xmlns:wsp="http://schemas.**xmlsoap.org/ws/2004/09/policy<http://schemas.xmlsoap.org/ws/2004/09/policy>
"**>
<wsp:ExactlyOne>
<wsp:All>
<sp:SupportingTokens xmlns:sp="
http://docs.oasis-open.org/ws-**sx/ws-securitypolicy/200702<http://docs.oasis-open.org/ws-sx/ws-securitypolicy/200702>
">
<wsp:Policy>
<sp:UsernameToken sp:IncludeToken="
http://docs.oasis-open.org/ws-**sx/ws-securitypolicy/200702/**
IncludeToken/AlwaysToRecipient<http://docs.oasis-open.org/ws-sx/ws-securitypolicy/200702/IncludeToken/AlwaysToRecipient>
**"
/>
</wsp:Policy>
</sp:SupportingTokens>
</wsp:All>
</wsp:ExactlyOne>
</wsp:Policy>
so I decided that this is a WS-SecurityPolicy use case my client should
authenticate itself this way
Map ctx = ((BindingProvider)port).**getRequestContext();
ctx.put("ws-security.username"**, "aname");
ctx.put("ws-security.callback-**handler",
PasswordCallback.class.**getName());
Unfortunately, I'm getting the following stack trace
WARNING: Interceptor for {
http://www.xmlns.enterprise.**com/HRM/WorkforceAdmin/**service/**
GetAllEmployeesInfoImpl/1.0/}**Get<http://www.xmlns.enterprise.com/HRM/WorkforceAdmin/service/GetAllEmployeesInfoImpl/1.0/%7DGet>
<http://www.xmlns.**walmartstores.com/HRM/**WorkforceAdmin/service/**
GetGlobalAssociateInfoImpl/1.**0/%7DGetGlobalAssoc<http://www.xmlns.walmartstores.com/HRM/WorkforceAdmin/service/GetGlobalAssociateInfoImpl/1.0/%7DGetGlobalAssoc>
AllEmployees<http://www.xmlns.**walmartstores.com/HRM/**
WorkforceAdmin/service/**GetGlobalAssociateInfoImpl/1.**
0/%7DGetGlobalAssoc<http://www.xmlns.walmartstores.com/HRM/WorkforceAdmin/service/GetGlobalAssociateInfoImpl/1.0/%7DGetGlobalAssoc>
}<http://mlns.walmartstores.**com/HRM/WorkforceAdmin/wsdl/**
GetGlobalAssociateInfoIntf/1.**0/%7DgetPersonalProfile<http://mlns.walmartstores.com/HRM/WorkforceAdmin/wsdl/GetGlobalAssociateInfoIntf/1.0/%7DgetPersonalProfile>
GetAllEmployeesInfoImpl#{http:**//x <http://x><http://www.xmlns.**
walmartstores.com/HRM/**WorkforceAdmin/service/**
GetGlobalAssociateInfoImpl/1.**0/%7DGetGlobalAssoc<http://www.xmlns.walmartstores.com/HRM/WorkforceAdmin/service/GetGlobalAssociateInfoImpl/1.0/%7DGetGlobalAssoc>
mlns.enterprise<http://www.**xmlns.walmartstores.com/HRM/**
WorkforceAdmin/service/**GetGlobalAssociateInfoImpl/1.**
0/%7DGetGlobalAssoc<http://www.xmlns.walmartstores.com/HRM/WorkforceAdmin/service/GetGlobalAssociateInfoImpl/1.0/%7DGetGlobalAssoc>
.com/HRM/WorkforceAdmin/wsdl/**GetAllEmployees<http://www.**
xmlns.walmartstores.com/HRM/**WorkforceAdmin/service/**
GetGlobalAssociateInfoImpl/1.**0/%7DGetGlobalAssoc<http://www.xmlns.walmartstores.com/HRM/WorkforceAdmin/service/GetGlobalAssociateInfoImpl/1.0/%7DGetGlobalAssoc>
InfoIntf/**1.0/}getPersonalProfile
has thrown exception, unwinding now
org.apache.cxf.ws.policy.**PolicyException: No username available
at
org.apache.cxf.ws.security.**wss4j.**UsernameTokenInterceptor.**
policyNotAsserted(**UsernameTokenInterceptor.java:**398)
at
org.apache.cxf.ws.security.**wss4j.**UsernameTokenInterceptor.**
addUsernameToken(**UsernameTokenInterceptor.java:**341)
at
org.apache.cxf.ws.security.**wss4j.**UsernameTokenInterceptor.**
addUsernameToken(**UsernameTokenInterceptor.java:**267)
at
org.apache.cxf.ws.security.**wss4j.**UsernameTokenInterceptor.**
handleMessage(**UsernameTokenInterceptor.java:**112)
at
org.apache.cxf.ws.security.**wss4j.**UsernameTokenInterceptor.**
handleMessage(**UsernameTokenInterceptor.java:**76)
at
org.apache.cxf.phase.**PhaseInterceptorChain.**doIntercept(**
PhaseInterceptorChain.java:**263)
at org.apache.cxf.endpoint.**ClientImpl.doInvoke(**
ClientImpl.java:533)
at org.apache.cxf.endpoint.**ClientImpl.invoke(ClientImpl.**
java:463)
at org.apache.cxf.endpoint.**ClientImpl.invoke(ClientImpl.**
java:366)
at org.apache.cxf.endpoint.**ClientImpl.invoke(ClientImpl.**
java:319)
at
org.apache.cxf.frontend.**ClientProxy.invokeSync(**ClientProxy.java:88)
at
org.apache.cxf.jaxws.**JaxWsClientProxy.invoke(**
JaxWsClientProxy.java:134)
at $Proxy29.getPersonalProfile(**Unknown Source)
at
com.rsa.pso.common.ws.hcm.**client.HcmClient.main(**HcmClient.java:95)
Exception in thread "main" javax.xml.ws.soap.**SOAPFaultException: No
username available
at
org.apache.cxf.jaxws.**JaxWsClientProxy.invoke(**
JaxWsClientProxy.java:156)
at $Proxy29.getPersonalProfile(**Unknown Source)
at
com.rsa.pso.common.ws.hcm.**client.HcmClient.main(**HcmClient.java:95)
Caused by: org.apache.cxf.ws.policy.**PolicyException: No username
available
at
org.apache.cxf.ws.security.**wss4j.**UsernameTokenInterceptor.**
policyNotAsserted(**UsernameTokenInterceptor.java:**398)
at
org.apache.cxf.ws.security.**wss4j.**UsernameTokenInterceptor.**
addUsernameToken(**UsernameTokenInterceptor.java:**341)
at
org.apache.cxf.ws.security.**wss4j.**UsernameTokenInterceptor.**
addUsernameToken(**UsernameTokenInterceptor.java:**267)
at
org.apache.cxf.ws.security.**wss4j.**UsernameTokenInterceptor.**
handleMessage(**UsernameTokenInterceptor.java:**112)
at
org.apache.cxf.ws.security.**wss4j.**UsernameTokenInterceptor.**
handleMessage(**UsernameTokenInterceptor.java:**76)
at
org.apache.cxf.phase.**PhaseInterceptorChain.**doIntercept(**
PhaseInterceptorChain.java:**263)
at org.apache.cxf.endpoint.**ClientImpl.doInvoke(**
ClientImpl.java:533)
at org.apache.cxf.endpoint.**ClientImpl.invoke(ClientImpl.**
java:463)
at org.apache.cxf.endpoint.**ClientImpl.invoke(ClientImpl.**
java:366)
at org.apache.cxf.endpoint.**ClientImpl.invoke(ClientImpl.**
java:319)
at
org.apache.cxf.frontend.**ClientProxy.invokeSync(**ClientProxy.java:88)
at
org.apache.cxf.jaxws.**JaxWsClientProxy.invoke(**
JaxWsClientProxy.java:134)
What am doing wrong, please? TIA,
--
Glen Mazza
Talend Community Coders
coders.talend.com
blog: www.jroller.com/gmazza
--
Aaron Stromas
Mobile: +1 703 203 9169
--
Glen Mazza
Talend Community Coders
coders.talend.com
blog: www.jroller.com/gmazza