Hi, Following proxy can be used to get the response you want from the web service. Property and Log mediators in this proxy are not required for your task. I just used those to get the 'Rate' in to a property and Log it.
<proxy name="TestProxy" startOnLoad="true" trace="disable" transports="https http"> <description/> <target> <inSequence> <call> <endpoint> <address uri=" http://www.webservicex.net/CurrencyConvertor.asmx"/> </endpoint> </call> <property expression="//web:ConversionRateResponse/web:ConversionRateResult" name="Rate" scope="default" type="STRING" xmlns:web=" http://www.webserviceX.NET/"/> <log level="full"> <property expression="get-property('Rate')" name="RATE"/> </log> </inSequence> </target> </proxy> If we can't use xpath expressions inside properties in Class mediator, you will have to try what Malaka has suggested. That part is not done in above config. Anyway if you send below request to above proxy you can get the proper response from the web service. <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:web="http://www.webserviceX.NET/"> <soapenv:Header/> <soapenv:Body> <web:ConversionRate> <web:FromCurrency>AUD</web:FromCurrency> <web:ToCurrency>LKR</web:ToCurrency> </web:ConversionRate> </soapenv:Body> </soapenv:Envelope> Backend Log : [2015-06-23 13:28:07,275] INFO - LogMediator To: http://www.w3.org/2005/08/addressing/anonymous, WSAction: , SOAPAction: , MessageID: urn:uuid:8af82eef-84e9-4404-97c3-a53338279550, Direction: request, *RATE = 103.5322*, Envelope: <?xml version='1.0' encoding='utf-8'?><soap:Envelope xmlns:soap=" http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd=" http://www.w3.org/2001/XMLSchema" xmlns:xsi=" http://www.w3.org/2001/XMLSchema-instance"><soap:Body><ConversionRateResponse xmlns="http://www.webserviceX.NET/ "><ConversionRateResult>103.5322</ConversionRateResult></ConversionRateResponse></soap:Body></soap:Envelope> Regards, Sandapa On Mon, Jun 22, 2015 at 3:21 PM, Aaquibah Nashry <nas...@wso2.com> wrote: > well..this is my task... > i have written a proxy > i need to call a webservice ( > http://www.webservicex.net/CurrencyConvertor.asmx?WSDL) and get the > return value (the currency exchange rate) and pass that value to a class > mediator. > How could this be done? > > > > Thanks and Regards, > > M.R.Aaquibah Nashry > *Intern, Engineering**| **WSO2, Inc.* > Mobile : +94 773946123 > Tel : +94 112662541 > Email : nas...@wso2.com <nas...@wso2.com> > > On Mon, Jun 22, 2015 at 3:08 PM, Sandapa Handakumbura <sand...@wso2.com> > wrote: > >> If you can tell me the exact requirement, I can help you with the config. >> Using the Payload factory mediator after the Call mediator will not make >> any difference for the first web service call. >> >> What is the request that you're sending to the proxy service? Isn't it >> something like this? >> >> <soapenv:Envelope xmlns:soapenv=" >> http://schemas.xmlsoap.org/soap/envelope/" xmlns:web=" >> http://www.webserviceX.NET/"> >> <soapenv:Header/> >> <soapenv:Body> >> <web:ConversionRate> >> <web:FromCurrency>AUD</web:FromCurrency> >> <web:ToCurrency>LKR</web:ToCurrency> >> </web:ConversionRate> >> </soapenv:Body> >> </soapenv:Envelope> >> >> If the request has required information Call mediator can send it to the >> web service and get the correct response. >> >> Regards, >> Sandapa >> >> On Mon, Jun 22, 2015 at 2:54 PM, Aaquibah Nashry <nas...@wso2.com> wrote: >> >>> Hi Sandapa, >>> I need to call it using the call mediator. >>> >>> I did the following modifications, >>> >>> <call> >>> <endpoint> >>> <address uri=" >>> http://www.webservicex.net/CurrencyConvertor.asmx?WSDL"/> >>> </endpoint> >>> </call> >>> <header name="Action" value=" >>> http://www.webserviceX.NET/ConversionRate"/> >>> <payloadFactory media-type="xml"> >>> <format> >>> <m0:ConversionRate xmlns:m0="http://www.webserviceX.NET/ >>> "> >>> <m0:request> >>> <m0:FromCurrency>EUR</m0:FromCurrency> >>> <m0:ToCurrency>USD</m0:ToCurrency> >>> </m0:request> >>> </m0:ConversionRate> >>> </format> >>> <args/> >>> </payloadFactory> >>> <log level="full"/> >>> >>> >>> >>> in the terminal i get the following when i try the proxy using 'try it' >>> >>> [2015-06-22 14:35:04,184] INFO {SERVICE_LOGGER.SalesForceProxy} - >>> Connection = Login to Salesforce ..... >>> [2015-06-22 14:35:05,840] INFO {SERVICE_LOGGER.SalesForceProxy} - To: >>> http://www.w3.org/2005/08/addressing/anonymous, WSAction: >>> http://www.webserviceX.NET/ConversionRate, SOAPAction: >>> http://www.webserviceX.NET/ConversionRate, MessageID: >>> urn:uuid:67c0e1d0-ac7d-496a-9cac-7779e7370791, Direction: request, >>> Envelope: <?xml version="1.0" encoding="utf-8"?><soap:Envelope xmlns:soap=" >>> http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd=" >>> http://www.w3.org/2001/XMLSchema" xmlns:xsi=" >>> http://www.w3.org/2001/XMLSchema-instance"><soap:Body><m0:ConversionRate >>> xmlns:m0="http://www.webserviceX.NET/ >>> "><m0:request><m0:FromCurrency>EUR</m0:FromCurrency><m0:ToCurrency>USD</m0:ToCurrency></m0:request></m0:ConversionRate></soap:Body></soap:Envelope> >>> >>> >>> Why am i not getting the response from the webservice? >>> >>> Thanks and Regards, >>> >>> M.R.Aaquibah Nashry >>> *Intern, Engineering**| **WSO2, Inc.* >>> Mobile : +94 773946123 >>> Tel : +94 112662541 >>> Email : nas...@wso2.com <nas...@wso2.com> >>> >>> On Mon, Jun 22, 2015 at 2:40 PM, Sandapa Handakumbura <sand...@wso2.com> >>> wrote: >>> >>>> Hi Aaquibah, >>>> >>>> FromCurrency and ToCurrency should be sent in the request. So you can >>>> simply invoke the service using a tool like SoapUI. Did you try that >>>> option? >>>> >>>> >>>> >>>> >>>> >>>> Regards, >>>> Sandapa >>>> >>>> >>>> On Mon, Jun 22, 2015 at 12:11 PM, Aaquibah Nashry <nas...@wso2.com> >>>> wrote: >>>> >>>>> Hi, >>>>> i am trying to get the current currency exchange rate from EUR to USD >>>>> from a webservice. i used a call mediator as follows: >>>>> >>>>> <call> >>>>> <endpoint> >>>>> <address uri=" >>>>> http://www.webservicex.net/CurrencyConvertor.asmx?WSDL"/> >>>>> </endpoint> >>>>> </call> >>>>> >>>>> I need to send the FromCurrency and the ToCurrency to the webservice >>>>> and get the rate. How can i do this? >>>>> >>>>> Also, >>>>> how can i store the value returned, in my proxy and then send this >>>>> value into a class mediator that i have written. >>>>> <class name="mediator.CustomMediator"> >>>>> <property name="rate" value="100"/> >>>>> </class> >>>>> I want to send the rate instead of the value 100 >>>>> >>>>> >>>>> >>>>> Please help... >>>>> >>>>> Thanks and Regards, >>>>> >>>>> M.R.Aaquibah Nashry >>>>> *Intern, Engineering**| **WSO2, Inc.* >>>>> Mobile : +94 773946123 >>>>> Tel : +94 112662541 >>>>> Email : nas...@wso2.com <nas...@wso2.com> >>>>> >>>>> _______________________________________________ >>>>> Dev mailing list >>>>> Dev@wso2.org >>>>> http://wso2.org/cgi-bin/mailman/listinfo/dev >>>>> >>>>> >>>> >>>> >>>> -- >>>> Sandapa Handakumbura >>>> Associate Technical Lead >>>> WSO2.Inc. ; http://wso2.com/ >>>> M : +94777115866 >>>> >>> >>> >> >> >> -- >> Sandapa Handakumbura >> Associate Technical Lead >> WSO2.Inc. ; http://wso2.com/ >> M : +94777115866 >> > > -- Sandapa Handakumbura Associate Technical Lead WSO2.Inc. ; http://wso2.com/ M : +94777115866
_______________________________________________ Dev mailing list Dev@wso2.org http://wso2.org/cgi-bin/mailman/listinfo/dev