*
The moose likes BEA/Weblogic and the fly likes Please tell how to authenticate user for calling webservice using JAX-WS Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Products » BEA/Weblogic
Bookmark "Please tell how to authenticate user for calling webservice using JAX-WS" Watch "Please tell how to authenticate user for calling webservice using JAX-WS" New topic
Author

Please tell how to authenticate user for calling webservice using JAX-WS

rajabhayya Sekharbhayya
Greenhorn

Joined: Oct 23, 2008
Posts: 14
I have the main program like below
import java.util.ArrayList;

import javax.jws.WebService;
import javax.security.*;

import org.csapi.schema.parlayx.common.v2_1.SimpleReference;
import org.csapi.schema.parlayx.presence.consumer.v2_3.local.SubscribePresence;
import org.csapi.schema.parlayx.presence.v2_3.PresenceAttributeType;

import org.csapi.wsdl.parlayx.presence.consumer.v2_3.service.PolicyException;
import org.csapi.wsdl.parlayx.presence.consumer.v2_3.service.PresenceConsumerService;
import org.csapi.wsdl.parlayx.presence.consumer.v2_3.service.PresenceConsumer;

import org.csapi.wsdl.parlayx.presence.consumer.v2_3.service.ServiceException;

import weblogic.jws.Policy;
import weblogic.jws.security.SecurityIdentity;
import weblogic.jws.security.SecurityRole;

public class Main {

public static void main(String[] args) throws PolicyException,
ServiceException

{
try {
PresenceConsumerService pcs_impl = new PresenceConsumerService();
System.out.println(" in full ccccccccc");

ArrayList<PresenceAttributeType> emps = new ArrayList<PresenceAttributeType>();

PresenceConsumer pc = (PresenceConsumer) pcs_impl
.getPresenceConsumer();
// create credential provider and set it to the Stub
SimpleReference rf = new SimpleReference();
rf.setCorrelator("correlatorid");
rf.setEndpoint("https://localhost:8002/PresenceConsumerService/services/PresenceConsumer");
rf.setInterfaceName("PresenceConsumer");
SubscribePresence sb = new SubscribePresence();
sb.setApplication("sdp");
sb.setPresentity("tel:1234");
sb.setReference(rf);
System.out.println(" Before calling subscribe presence ==");
pc.subscribePresence("tel:5555", emps, "sdp", rf);
} catch (Exception e) {
e.printStackTrace();
}
}
}



When I run the program, i got the error as below

in full ccccccccc
Before calling subscribe presence ==
javax.xml.ws.soap.SOAPFaultException: No Security header in message but required by policy.
at com.sun.xml.ws.fault.SOAP11Fault.getProtocolException(SOAP11Fault.java:188)
at com.sun.xml.ws.fault.SOAPFaultBuilder.createException(SOAPFaultBuilder.java:108)
at com.sun.xml.ws.client.sei.SyncMethodHandler.invoke(SyncMethodHandler.java:119)
at com.sun.xml.ws.client.sei.SyncMethodHandler.invoke(SyncMethodHandler.java:89)
at com.sun.xml.ws.client.sei.SEIStub.invoke(SEIStub.java:118)
at $Proxy34.subscribePresence(Unknown Source)
at Main.main(Main.java:44)



Please find build.xml that generated the classes


<project name="webservices-simple_client" default="all">
<!-- set global properties for this -->
<property name="wls.hostname" value="localhost" />
<property name="wls.port" value="8002" />
<property name="example-output" value="output" />
<property name="clientclass-dir" value="${example-output}/srcclasses" />
<property name="clientclassfiles-dir" value="${example-output}/classfiles" />
<path id="client.class.path">
<pathelement path="${clientclass-dir}" />
<pathelement path="${java.class.path}" />
</path>
<taskdef name="clientgen" classname="weblogic.wsee.tools.anttasks.ClientGenTask" />
<target name="clean">
<delete dir="${clientclass-dir}" />
<delete dir="../src/com/bea/wlcp/wlng/ws/presence" />
<delete dir="../src/org/csapi/schema/paralyx/common/v2_1" />
<delete dir="../src/org/csapi/schema/paralyx/presence/consumer/v2_3/local" />
<delete dir="../src/org/csapi/schema/parlayx/presence/v2_3" />
<echo message="Cleaning Completed" />
</target>
<target name="build-client">
<clientgen wsdl="http://${wls.hostname}:${wls.port}/parlayx21/presence/PresenceConsumer?WSDL" destdir="${clientclass-dir}" generatePolicyMethods="true" type="JAXWS"/>
<javac srcdir="${clientclass-dir}" destdir="${clientclassfiles-dir}" includes="**/*.java" />
<copy overwrite="true" todir="../src">
<fileset dir="${clientclass-dir}" />
</copy>
<copy overwrite="true" todir="../src">
<fileset dir="${clientclassfiles-dir}" />
</copy>
<delete dir="${clientclass-dir}" />
<delete dir="${clientclassfiles-dir}" />
<echo message="Building Completed" />
</target>
<target name="all" depends="clean,build-client" />
</project>



please find the WSDL file


<?xml version="1.0" encoding="UTF-8" ?>
- <s0:definitions name="presence_consumer_service" targetNamespace="http://www.csapi.org/wsdl/parlayx/presence/consumer/v2_3/service" xmlns="" xmlns:s0="http://schemas.xmlsoap.org/wsdl/" xmlns:s1="http://schemas.xmlsoap.org/ws/2004/09/policy" xmlns:s2="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd" xmlns:s3="http://www.csapi.org/wsdl/parlayx/presence/consumer/v2_3/interface" xmlns:s4="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:s5="http://www.csapi.org/wsdl/parlayx/presence/consumer/v2_3/service" xmlns:wsp="http://schemas.xmlsoap.org/ws/2004/09/policy">
<s0:import location="http://localhost:8002/parlayx21/presence/PresenceConsumer?WSDL/parlayx_presence_consumer_interface_2_3.wsdl" namespace="http://www.csapi.org/wsdl/parlayx/presence/consumer/v2_3/interface" />
- <s1:Policy s2:Id="Auth.xml">
- <wssp:Identity xmlns:wssp="http://www.bea.com/wls90/security/policy">
- <wssp:SupportedTokens>
- <wssp:SecurityToken TokenType="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-username-token-profile-1.0#UsernameToken">
<wssp:UsePassword Type="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-username-token-profile-1.0#PasswordText" />
</wssp:SecurityToken>
<wssp:SecurityToken TokenType="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-x509-token-profile-1.0#X509v3" />
</wssp:SupportedTokens>
</wssp:Identity>
</s1:Policy>
<wsp:UsingPolicy s0:Required="true" />
- <s0:binding name="PresenceConsumerBinding" type="s3:PresenceConsumer">
<s4:binding style="document" transport="http://schemas.xmlsoap.org/soap/http" />
- <s0peration name="subscribePresence">
<s4peration style="document" />
- <s0:input>
<s4:body use="literal" />
- <wsp:Policy>
<wsp:PolicyReference URI="#Auth.xml" />
</wsp:Policy>
</s0:input>
- <s0utput>
<s4:body use="literal" />
</s0utput>
- <s0:fault name="ServiceException">
<s4:fault name="ServiceException" use="literal" />
</s0:fault>
- <s0:fault name="PolicyException">
<s4:fault name="PolicyException" use="literal" />
</s0:fault>
</s0peration>
- <s0peration name="getUserPresence">
<s4peration style="document" />
- <s0:input>
<s4:body use="literal" />
- <wsp:Policy>
<wsp:PolicyReference URI="#Auth.xml" />
</wsp:Policy>
</s0:input>
- <s0utput>
<s4:body use="literal" />
</s0utput>
- <s0:fault name="ServiceException">
<s4:fault name="ServiceException" use="literal" />
</s0:fault>
- <s0:fault name="PolicyException">
<s4:fault name="PolicyException" use="literal" />
</s0:fault>
</s0peration>
- <s0peration name="startPresenceNotification">
<s4peration style="document" />
- <s0:input>
<s4:body use="literal" />
- <wsp:Policy>
<wsp:PolicyReference URI="#Auth.xml" />
</wsp:Policy>
</s0:input>
- <s0utput>
<s4:body use="literal" />
</s0utput>
- <s0:fault name="ServiceException">
<s4:fault name="ServiceException" use="literal" />
</s0:fault>
- <s0:fault name="PolicyException">
<s4:fault name="PolicyException" use="literal" />
</s0:fault>
</s0peration>
- <s0peration name="endPresenceNotification">
<s4peration style="document" />
- <s0:input>
<s4:body use="literal" />
- <wsp:Policy>
<wsp:PolicyReference URI="#Auth.xml" />
</wsp:Policy>
</s0:input>
- <s0utput>
<s4:body use="literal" />
</s0utput>
- <s0:fault name="ServiceException">
<s4:fault name="ServiceException" use="literal" />
</s0:fault>
- <s0:fault name="PolicyException">
<s4:fault name="PolicyException" use="literal" />
</s0:fault>
</s0peration>
</s0:binding>
- <s0:service name="PresenceConsumerService">
- <s0:port binding="s5:PresenceConsumerBinding" name="PresenceConsumer">
<s4:address location="http://localhost:8002/parlayx21/presence/PresenceConsumer" />
</s0:port>
</s0:service>
</s0:definitions>




From wsdl , wht type of security policies I am not understanding what is required to perform authentication


please let me know how to implement the simple username password authentication using jax-ws , i studied so many articles, but could not find correctly exactly wht are the steps to authenticate while invoking webservice

Thanks in Advance

Rajsekhar



 
Don't get me started about those stupid light bulbs.
 
subject: Please tell how to authenticate user for calling webservice using JAX-WS
 
Similar Threads
Ant build - With weblogic 10
MTOM example
Getting Exception :Problem: failed to create task or type arg in build.xml while creating webservice
Trying to generate webservice using clientgen in build.xml
Need Java Client stubs for given WSDL