1. I have created a web service with this simple method. Here is  
SiService.java
publicclassSiService{publicStringecho(Stringarg){returnarg;}
}
2.To  add a security to my web service I've done this:
        * I have added a PWCBHandler.java  class (here is the code)
publicclassPWCBHandlerimplementsCallbackHandler{publicvoidhandle(Callback[]callbacks)throwsIOException,UnsupportedCallbackException{for(inti
 =0;i <callbacks.length;i++){WSPasswordCallbackpwcb 
=(WSPasswordCallback)callbacks[i];//String id = 
pwcb.getIdentifier();if(pwcb.getIdentifier().equals("bob")){pwcb.setPassword("bobPW");}}}
}
        *       * in the servies.xml I have engaged the rampart module and 
added this parameter. Now it looks this way:
<service name="SiService">

<moduleref="rampart"/>

<Description>Typeyour description here </Description>

<messageReceivers><messageReceiver 
mep="http://www.w3.org/2004/08/wsdl/in-only"class="org.apache.axis2.rpc.receivers.RPCInOnlyMessageReceiver"/>


<messageReceiver  
mep="http://www.w3.org/2004/08/wsdl/in-out"class="org.apache.axis2.rpc.receivers.RPCMessageReceiver"/></messageReceivers><parameter
 name="ServiceClass"locked="false">nlo.SiService</parameter>


<parameter name="InflowSecurity">

<action><items>UsernameToken</items><passwordCallbackClass>com.gi.PWCBHandler</passwordCallbackClass>
</action>

</parameter>

</service>




but now when I try this request  from javascript:

if(window.XMLHttpRequest){xmlhttp =newXMLHttpRequest();}else{xmlhttp 
=newActiveXObject("Microsoft.XMLHTTP");}functionloadXMLDoc(){xmlhttp.onreadystatechange
 =function(){if(xmlhttp.readyState==4&&xmlhttp.status==200){varxmlObj 
=xmlhttp.responseXML;alert 
(xmlhttp.responseText);}}xmlhttp.open("GET","http://localhost:9091/ztest/services/SiService/echo?arg=Helllo",true);xmlhttp.send();}
I see that the exception :missing security header 
Is there any way I can add the security header in this requrst because I have 
done it only in web service client in java. Thank you in advance. 

Reply via email to