Eric,

In a slightly later response to your email,
Hakon Sagehaug provides additional details to check.

What I normally do for a simple secured ws is
1.Construct the wsdl and add some policy to a operation/porttype etc
2.Generate the code with axis2 wsdl2code
3.Add the policy to the services.xml usually in a operation element and engaging rampart as a module for the service. 4. make the client program, using the stub created. This client will then also have the policy from the wsdl embedded in the generated code, you can see this I you have access to the source code of the stub you are using. And add username/password and explaned in a earlier mail.

One detail he did not mention, however, is that these steps work ONLY IF you are using WSDL 1.1
to describe your service.
IF you use WSDL 2.0, then the WSDL2Java utility does NOT embed the policy into the generated stub. There is a JIRA about this: AXIS2-4272 Service stub missing WS-Policy information when codegen with WSDL20


Ed Komp


Thanks again Hakon....

My code is as follows:


String userid = "aUserId";
ConfigurationContext ctx =
ConfigurationContextFactory .createConfigurationContextFromFileSystem("C:\\dir1\\dir2\\dir3\\");
UserProfileStub stub = new UserProfileStub (ctx );
ServiceClient serviceClient = stub._getServiceClient(); 
serviceClient.engageModule("rampart");
                
Options options = serviceClient.getOptions();
options.setUserName("myUserName");
options.setPassword("myPassword");
                
serviceClient.setOptions(options);
                
AccessAssignment[] aa =
stub.getUserAccessAssignmentsByUserId(userId).get_return();


The following exception is thrown on the last line of code. I'm guessing it is because the web service being consumed is time sensitive. Are there any other options i should be setting for this? Or something else I have
to add to the axis2.xml?

[4/27/09 14:49:00:515 MDT] 00000063 SystemErr     R
org.apache.axis2.AxisFault: WSDoAllReceiver: Incoming message does not
contain required Security header
[4/27/09 14:49:00:515 MDT] 00000063 SystemErr     R     at
org .apache .axis2.util.Utils.getInboundFaultFromMessageContext(Utils.java:512)
[4/27/09 14:49:00:515 MDT] 00000063 SystemErr     R     at
org .apache .axis2 .description .OutInAxisOperationClient.handleResponse(OutInAxisOperation.java:370)
[4/27/09 14:49:00:515 MDT] 00000063 SystemErr     R     at
org .apache .axis2 .description.OutInAxisOperationClient.send(OutInAxisOperation.java: 416)
[4/27/09 14:49:00:515 MDT] 00000063 SystemErr     R     at
org .apache .axis2 .description .OutInAxisOperationClient.executeImpl(OutInAxisOperation.java:228)
[4/27/09 14:49:00:515 MDT] 00000063 SystemErr     R     at
org.apache.axis2.client.OperationClient.execute(OperationClient.java: 163)

Thanks,
Eric

Reply via email to