axis-java-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Sagara Gunathunga <sagara.gunathu...@gmail.com>
Subject Re: how to call web service with rampart?
Date Thu, 03 Mar 2011 07:33:25 GMT
On Wed, Mar 2, 2011 at 10:53 PM, andrew vn <andrewvn2010@gmail.com> wrote:

> I checked again the Converter service without client code. Here is the way
> i checked:
>
> *
> http://localhost:8081/ConverterProj/services/Converter/celsiusToFarenheit?celsius=100
> *
>
> It made the following errors:
>
> *HTTP Status 500 -
>
> type Exception report
>
> message
>
> description The server encountered an internal error () that prevented it
> from fulfilling this request.
>
> exception
>
> javax.servlet.ServletException: Servlet execution threw an exception
>
> root cause
>
> java.lang.NoClassDefFoundError: org/apache/axis2/mex/MexException
>
>     org.apache.rampart.RampartEngine.process(RampartEngine.java:75)
>
> org.apache.rampart.handler.RampartReceiver.invoke(RampartReceiver.java:92)
>     org.apache.axis2.engine.Phase.invoke(Phase.java:318)
>     org.apache.axis2.engine.AxisEngine.invoke(AxisEngine.java:254)
>     org.apache.axis2.engine.AxisEngine.receive(AxisEngine.java:160)
>
> org.apache.axis2.transport.http.util.RESTUtil.invokeAxisEngine(RESTUtil.java:135)
>
> org.apache.axis2.transport.http.util.RESTUtil.processURLRequest(RESTUtil.java:130)
>
> org.apache.axis2.transport.http.AxisServlet$RestRequestProcessor.processURLRequest(AxisServlet.java:817)
>     org.apache.axis2.transport.http.AxisServlet.doGet(AxisServlet.java:267)
>     javax.servlet.http.HttpServlet.service(HttpServlet.java:617)
>
>     javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
>
> root cause
>
> java.lang.ClassNotFoundException: org.apache.axis2.mex.MexException*


 Are you sure you have mex-x-impl.jar on your service classpath  ?


*
>
>
> org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1680)
>
> org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1526)
>      org.apache.rampart.RampartEngine.process(RampartEngine.java:75)
>
> org.apache.rampart.handler.RampartReceiver.invoke(RampartReceiver.java:92)
>     org.apache.axis2.engine.Phase.invoke(Phase.java:318)
>     org.apache.axis2.engine.AxisEngine.invoke(AxisEngine.java:254)
>     org.apache.axis2.engine.AxisEngine.receive(AxisEngine.java:160)
>
> org.apache.axis2.transport.http.util.RESTUtil.invokeAxisEngine(RESTUtil.java:135)
>
> org.apache.axis2.transport.http.util.RESTUtil.processURLRequest(RESTUtil.java:130)
>
> org.apache.axis2.transport.http.AxisServlet$RestRequestProcessor.processURLRequest(AxisServlet.java:817)
>     org.apache.axis2.transport.http.AxisServlet.doGet(AxisServlet.java:267)
>     javax.servlet.http.HttpServlet.service(HttpServlet.java:617)
>
>     javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
>
> note The full stack trace of the root cause is available in the Apache
> Tomcat/6.0.32 logs.*
>
> But when I removed *<module ref="rampart" />* from *services.xml*. It
> works fine!


 Yes , when you  engage rampart module  it try to deploy and look for
dependencies.


Thanks !


>
>
>
> On 27 February 2011 00:36, andrew vn <andrewvn2010@gmail.com> wrote:
>
>> I use another method to call web service. I could make a SOAP request, but
>> i can't receive the response because the parameter that is transfer is *
>> String*  type.
>>
>> *SOAP Request:*
>>
>> <?xml version="1.0" encoding="http://schemas.xmlsoap.org/soap/envelope/"
>> standalone="no"?>
>> <soapenv:Envelope xmlns:soapenv="
>> http://schemas.xmlsoap.org/soap/envelope/">
>> <soapenv:Header xmlns:wsa="http://www.w3.org/2005/08/addressing">
>> <wsse:Security xmlns:wsse="
>> http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd"
>> soapenv:mustUnderstand="1">
>> <wsse:UsernameToken xmlns:wsu="
>> http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd"
>> wsu:Id="UsernameToken-2">
>> <wsse:Username>apache</wsse:Username>
>> <wsse:Password Type="
>> http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-username-token-profile-1.0#PasswordText
>> ">password</wsse:Password>
>> </wsse:UsernameToken>
>> </wsse:Security>
>> <wsa:To>http://localhost:1234/ConverterProj/services/Converter</wsa:To>
>> <wsa:MessageID>urn:uuid:E21D3885A186948AC71298740519416</wsa:MessageID>
>> <wsa:Action>urn:celsiusToFarenheit</wsa:Action>
>> </soapenv:Header>
>> <soapenv:Body>
>> <ns1:celsiusToFarenheit xmlns:ns1="http://wtp">
>> <celsius>100</celsius>
>> </ns1:celsiusToFarenheit>
>> </soapenv:Body>
>> </soapenv:Envelope>
>>
>>
>> *SOAP Response
>> *
>> <?xml version="1.0" encoding="http://schemas.xmlsoap.org/soap/envelope/"
>> standalone="no"?>
>> <soapenv:Envelope xmlns:soapenv="
>> http://schemas.xmlsoap.org/soap/envelope/">
>> <soapenv:Header xmlns:wsa="http://www.w3.org/2005/08/addressing">
>> <wsa:Action>http://www.w3.org/2005/08/addressing/soap/fault</wsa:Action>
>> <wsa:RelatesTo>urn:uuid:E21D3885A186948AC71298740519416</wsa:RelatesTo>
>> </soapenv:Header>
>> <soapenv:Body>
>> <soapenv:Fault>
>> *<faultcode>soapenv:Server</faultcode>
>> <faultstring>java.lang.NoClassDefFoundError:
>> org/jaxen/JaxenException</faultstring>*
>> <detail/>
>> </soapenv:Fault>
>> </soapenv:Body>
>> </soapenv:Envelope>
>>
>> I want to ask how to set and send with *float* type. Here is my test
>> client code:
>>
>> package wtp;
>> import org.apache.axiom.om.OMNamespace;
>> import org.apache.axiom.om.OMElement;
>> import org.apache.axis2.client.Options;
>> import org.apache.axiom.om.OMFactory;
>> import org.apache.axis2.addressing.EndpointReference;
>>
>> import org.apache.axiom.om.OMAbstractFactory;
>> import org.apache.axis2.client.ServiceClient;
>>  import org.apache.axis2.context.ConfigurationContext;
>> import org.apache.axis2.context.ConfigurationContextFactory;
>>
>> public class TestClient {
>>
>>     private static EndpointReference targetEPR = new EndpointReference("
>> http://localhost:1234/ConverterProj/services/Converter");
>>
>>     public static void main(String[] args) {
>>         try {
>>             String axis2repository =
>> "/home/php/Downloads/metadata/.metadata/TestClient/WebContent/WEB-INF";
>>             String axis2xml =
>> "/home/php/Downloads/metadata/.metadata/TestClient/WebContent/WEB-INF/conf/axis2.xml";
>>
>>             ConfigurationContext configContext =
>> ConfigurationContextFactory.createConfigurationContextFromFileSystem(axis2repository,axis2xml);
>>             ServiceClient serviceClient = new
>> ServiceClient(configContext,null);
>>                serviceClient.engageModule("rampart");
>>             Options options = new Options();
>>                options.setAction("urn:celsiusToFarenheit");
>>                options.setTo(targetEPR);
>>                options.setUserName("apache");
>>                options.setPassword("password");
>>             serviceClient.setOptions(options);
>>
>>
>>            OMFactory omFactory = OMAbstractFactory.getOMFactory();
>>            OMNamespace omNamespace = omFactory.createOMNamespace ("
>> http://wtp","ns1");
>>
>>                 OMElement method1 =
>> omFactory.createOMElement("celsiusToFarenheit", omNamespace);
>>
>>                 OMElement valueCelsius =
>> omFactory.createOMElement("celsius", null);
>>                 valueCelsius.addChild(omFactory.createOMText(valueCelsius,
>> "100"));
>>
>>                 method1.addChild(valueCelsius);
>>
>>                 serviceClient.fireAndForget(method1); // Exception is
>> thrown in this line
>>                      Thread.sleep(1000000);
>>
>>                  OMElement result = serviceClient.sendReceive(method1);
>>                  System.out.println(result);
>>
>>         } catch (Exception e) {
>>             System.out.println(e.getMessage());
>>        }
>>     }
>> }
>>
>> Thanks in advanced
>>
>>
>> On 26 February 2011 20:20, Thilina Mahesh Buddhika <thilinamb@gmail.com>wrote:
>>
>>> You need to include the jaxen-* jar in your classpath along with other
>>> jars available in the lib directory of Axis2 distribution.
>>>
>>> Thanks,
>>> Thilina
>>>
>>>
>>> On Sat, Feb 26, 2011 at 9:47 AM, andrew vn <andrewvn2010@gmail.com>wrote:
>>>
>>>> I've already add 2 modules:* rampart.mar, rahas.ma*r and all* jar*files in
>>>> * lib* directory of rampart to my projects.
>>>>
>>>> I think that i make a mistake in client codes.
>>>>
>>>> Please take a look at my client code, is there any problem or missing?
>>>>
>>>> Thanks
>>>>
>>>> On 26 February 2011 11:07, Amarnath Reddy <amarnathreddy504@gmail.com>wrote:
>>>>
>>>>> Dear Andrew,
>>>>> You can solve this problem by placing all the libraries of axis21.5.1
>>>>> distribution jars of lib directory.
>>>>> And remove the eclipse added jars.
>>>>>
>>>>>
>>>>> On Sat, Feb 26, 2011 at 9:19 AM, Lasantha Bandara <
>>>>> lasanthasridinesh@gmail.com> wrote:
>>>>>
>>>>>> One simple solution is to add required java libraries into your
>>>>>> project. Those are in \axis2-1.5.1-bin\axis2-1.5.1\lib folder. It
will solve
>>>>>> many problems.
>>>>>>
>>>>>>
>>>>>> On Fri, Feb 25, 2011 at 7:31 PM, andrew vn <andrewvn2010@gmail.com>wrote:
>>>>>>
>>>>>>> Dear all,
>>>>>>>
>>>>>>> I'm new to axis2 and web service. I've already written a *Converter*service
genertated with tools:
>>>>>>>
>>>>>>>    - eclipse-helio
>>>>>>>    - jdk1.6.0_23
>>>>>>>    - axis2-1.5
>>>>>>>    - rapart-1.5.1
>>>>>>>
>>>>>>> Then, i'm writing a client to call this service, and now i want
to
>>>>>>> use *rampart* module to encrypt and sign the message.
>>>>>>>
>>>>>>> *Here is my service Converter code:*
>>>>>>>
>>>>>>> *Converter.java*
>>>>>>> package wtp;
>>>>>>> public class Converter
>>>>>>> {
>>>>>>>   public float celsiusToFarenheit ( float celsius )
>>>>>>>   {
>>>>>>>     return (celsius * 9 / 5) + 32;
>>>>>>>   }
>>>>>>>
>>>>>>>   public float farenheitToCelsius ( float farenheit )
>>>>>>>   {
>>>>>>>     return (farenheit - 32) * 5 / 9;
>>>>>>>   }
>>>>>>> }
>>>>>>> *PWCBHandler.java*
>>>>>>> package wtp;
>>>>>>>
>>>>>>> import org.apache.ws.security.WSPasswordCallback;
>>>>>>> import javax.security.auth.callback.Callback;
>>>>>>> import javax.security.auth.callback.CallbackHandler;
>>>>>>> import javax.security.auth.callback.UnsupportedCallbackException;
>>>>>>> import java.io.IOException;
>>>>>>>
>>>>>>> public class PWCBHandler implements CallbackHandler {
>>>>>>>
>>>>>>>      @SuppressWarnings("deprecation")
>>>>>>>     public void handle(Callback[] callbacks) throws IOException,
>>>>>>>      UnsupportedCallbackException {
>>>>>>>
>>>>>>>  for (int i = 0; i < callbacks.length; i++) {
>>>>>>>
>>>>>>>      //When the server side need to authenticate the user
>>>>>>>      WSPasswordCallback pwcb = (WSPasswordCallback)callbacks[i];
>>>>>>>      if (pwcb.getUsage() ==
>>>>>>> WSPasswordCallback.USERNAME_TOKEN_UNKNOWN) {
>>>>>>>          if(pwcb.getIdentifer().equals("apache") &&
>>>>>>> pwcb.getPassword().equals("password")) {
>>>>>>>              //If authentication successful, simply return
>>>>>>>              return;
>>>>>>>          } else {
>>>>>>>              throw new UnsupportedCallbackException(callbacks[i],
>>>>>>> "check failed");
>>>>>>>          }
>>>>>>>      }
>>>>>>>      //When the client requests for the password to be added
in to
>>>>>>> the
>>>>>>>      //UT element
>>>>>>>      pwcb.setPassword("password");
>>>>>>>  }
>>>>>>> }
>>>>>>> }
>>>>>>> *services.xml*
>>>>>>> <service name="Converter" >
>>>>>>>     <Description>
>>>>>>>         Test WS-Security
>>>>>>>     </Description>
>>>>>>>     <module ref="rampart"/>
>>>>>>>     <parameter name="InflowSecurity">
>>>>>>>       <action>
>>>>>>>         <items>UsernameToken</items>
>>>>>>>         <user>apache</user>
>>>>>>>
>>>>>>> <passwordCallbackClass>wtp.PWCBHandler</passwordCallbackClass>
>>>>>>>         <passwordType>PasswordText</passwordType>
>>>>>>>       </action>
>>>>>>>     </parameter>
>>>>>>>     <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">wtp.Converter</parameter>
>>>>>>> </service>
>>>>>>>
>>>>>>> *Here is my client code:*
>>>>>>> *
>>>>>>> ConverterClient.java*
>>>>>>>
>>>>>>> package wtp;
>>>>>>>
>>>>>>> import java.rmi.RemoteException;
>>>>>>>
>>>>>>> import org.apache.axis2.AxisFault;
>>>>>>> import org.apache.axis2.Constants;
>>>>>>> import org.apache.axis2.context.ConfigurationContext;
>>>>>>> import org.apache.axis2.context.ConfigurationContextFactory;
>>>>>>>
>>>>>>> import wtp.ConverterStub.CelsiusToFarenheit;
>>>>>>> import wtp.ConverterStub.CelsiusToFarenheitResponse;
>>>>>>>
>>>>>>> public class ConverterClient {
>>>>>>>
>>>>>>>         public static void main(String[] args) {
>>>>>>>                 try {
>>>>>>>                         float celsiusValue = 100;
>>>>>>>                        //ConverterStub stub = new ConverterStub("
>>>>>>> http://localhost:1234/ConverterProj/services/Converter");
>>>>>>>                         String axis2repository =
>>>>>>> "/home/hp/Downloads/metadata/.metadata/ConverterClient/WebContent/WEB-INF";
>>>>>>>                         //String axis2xml =
>>>>>>> "/home/hp/Downloads/metadata/.metadata/ConverterClient/WebContent/WEB-INF/conf/axis2.xml";
>>>>>>>
>>>>>>>                         ConfigurationContext configContext =
>>>>>>> ConfigurationContextFactory.createConfigurationContextFromFileSystem(axis2repository,null);
>>>>>>>                         ConverterStub stub = new
>>>>>>> ConverterStub(configContext, "
>>>>>>> http://localhost:8081/ConverterProj/services/Converter");
>>>>>>>                         //String targetEpr = "
>>>>>>> http://localhost:8081/ConverterProj/services/Converter";
>>>>>>>
>>>>>>> stub._getServiceClient().engageModule("rampart");
>>>>>>>
>>>>>>>
>>>>>>> stub._getServiceClient().getOptions().setUserName("apache");
>>>>>>>
>>>>>>> stub._getServiceClient().getOptions().setPassword("password");
>>>>>>>
>>>>>>> stub._getServiceClient().getOptions().setTransportInProtocol(Constants.TRANSPORT_HTTP);
>>>>>>>                         CelsiusToFarenheit c2f = new
>>>>>>> CelsiusToFarenheit();
>>>>>>>                         c2f.setCelsius(celsiusValue);
>>>>>>>                         CelsiusToFarenheitResponse res =
>>>>>>> stub.celsiusToFarenheit(c2f);
>>>>>>>                         System.out.println("Celsius :
>>>>>>> "+celsiusValue+" = "+"Farenheit : "+res.get_return());
>>>>>>>                 } catch (AxisFault e) {
>>>>>>>                         e.printStackTrace();
>>>>>>>                 } catch (RemoteException e) {
>>>>>>>                         e.printStackTrace();
>>>>>>>                 }
>>>>>>>
>>>>>>>         }
>>>>>>> }
>>>>>>>
>>>>>>>
>>>>>>> When i run client, it has the following errors:
>>>>>>>
>>>>>>> [ERROR] org/jaxen/JaxenException
>>>>>>> java.lang.NoClassDefFoundError: org/jaxen/JaxenException
>>>>>>>     at
>>>>>>> org.apache.rampart.RampartEngine.process(RampartEngine.java:75)
>>>>>>>     at
>>>>>>> org.apache.rampart.handler.RampartReceiver.invoke(RampartReceiver.java:92)
>>>>>>>     at org.apache.axis2.engine.Phase.invoke(Phase.java:318)
>>>>>>>     at org.apache.axis2.engine.AxisEngine.invoke(AxisEngine.java:254)
>>>>>>>     at
>>>>>>> org.apache.axis2.engine.AxisEngine.receive(AxisEngine.java:160)
>>>>>>>     at
>>>>>>> org.apache.axis2.transport.http.HTTPTransportUtils.processHTTPPostRequest(HTTPTransportUtils.java:173)
>>>>>>>     at
>>>>>>> org.apache.axis2.transport.http.AxisServlet.doPost(AxisServlet.java:144)
>>>>>>>     at javax.servlet.http.HttpServlet.service(HttpServlet.java:637)
>>>>>>>     at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
>>>>>>>     at
>>>>>>> org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
>>>>>>>     at
>>>>>>> org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
>>>>>>>     at
>>>>>>> org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)
>>>>>>>     at
>>>>>>> org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
>>>>>>>     at
>>>>>>> org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
>>>>>>>     at
>>>>>>> org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
>>>>>>>     at
>>>>>>> org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
>>>>>>>     at
>>>>>>> org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:298)
>>>>>>>     at
>>>>>>> org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:859)
>>>>>>>     at
>>>>>>> org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:588)
>>>>>>>     at
>>>>>>> org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:489)
>>>>>>>     at java.lang.Thread.run(Thread.java:662)
>>>>>>> Caused by: java.lang.ClassNotFoundException: org.jaxen.JaxenException
>>>>>>>     at
>>>>>>> org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1680)
>>>>>>>     at
>>>>>>> org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1526)
>>>>>>>     ... 21 more
>>>>>>>
>>>>>>> Please show me the way to resove this problems.
>>>>>>>
>>>>>>> Thanks
>>>>>>>
>>>>>>
>>>>>>
>>>>>>
>>>>>> --
>>>>>> *
>>>>>> Lasantha Bandara,
>>>>>> Computer Science and Engineering,
>>>>>> University of Moratuwa,
>>>>>> Sri Lanka.
>>>>>> *
>>>>>> blog: http://lasanthasri.blogspot.com/
>>>>>> gtalk: lasanthasridinesh
>>>>>> skype: lasanthasridinesh
>>>>>>
>>>>>>
>>>>>
>>>>>
>>>>> --
>>>>> Regards,
>>>>> Amarnath Redddy.G
>>>>> 91-9985923453.
>>>>>
>>>>
>>>>
>>>
>>>
>>> --
>>> Thilina Mahesh Buddhika
>>> http://blog.thilinamb.com
>>>
>>
>>
>


-- 
Sagara Gunathunga

Blog - http://ssagara.blogspot.com
Web - http://people.apache.org/~sagara/

Mime
View raw message