• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Tim Cooke
  • Jeanne Boyarsky
  • Liutauras Vilda
Sheriffs:
  • Frank Carver
  • Henry Wong
  • Ron McLeod
Saloon Keepers:
  • Tim Moores
  • Frits Walraven
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
Bartenders:
  • Al Hobbs
  • Piet Souris
  • Himai Minh

org.apache.axis.client.Call invoke method always returning string type

 
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
I am new to Web Services.
When i am invoking a method(this method returns a Big Decimal value) in WebService, am getting the result as String type always in client. But I need Big Decimal value in Client class.
Service service = new Service ();
Call call = (Call) service.createCall ();
call.setTargetEndpointAddress (new URL (endpoint));
call.setOperationName ("farenheitToCelsius");
<b>Object celToFar = call.invoke (new Object[] {BigDecimal.valueOf (64)});</b>
The method "farenheitToCelsius" always returns Big Decimal value. But in Client class 'celToFar' is getting as String instead of BigDecimal.
Please Help.
Full Code given below:


WebService Class
<code>
@WebService
public class TestWS
{
@WebMethod
public BigDecimal celsiusToFarenheit (BigDecimal temp)
{
BigDecimal result = temp.multiply (BigDecimal.valueOf (1.8)).add (BigDecimal.valueOf (32));
return result;
}

@WebMethod
public BigDecimal farenheitToCelsius (BigDecimal temp)
{
BigDecimal result = temp.subtract (BigDecimal.valueOf (32)).divide (BigDecimal.valueOf (1.8), 2,
RoundingMode.HALF_UP);
return result;
}

}
</code>
-----------------------------------------------------------------

Client Class
<code>
public class TestClient
{
public static void main (String[] args)
{
try
{

String endpoint = "http://localhost:8081/WebServices/services/TestWS";
Service service = new Service ();
Call call = (Call) service.createCall ();
call.setTargetEndpointAddress (new URL (endpoint));
call.setOperationName ("farenheitToCelsius");
<b>Object celToFar = call.invoke (new Object[] {BigDecimal.valueOf (64)});</b>
System.out.println ("celToFar::" + celToFar);
}
catch (Exception e)
{
System.err.println (e.toString ());
}
}
}
</code>
----------------------------------------------------------------------

TestWS.wsdl
<code>
<?xml version="1.0" encoding="UTF-8"?>
<wsdl:definitions targetNamespace="http://test.com" xmlns:apachesoap="http://xml.apache.org/xml-soap" xmlns:impl="http://test.com" xmlns:intf="http://test.com" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:wsdlsoap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<!--WSDL created by Apache Axis version: 1.4
Built on Apr 22, 2006 (06:55:48 PDT)-->
<wsdl:types>
<schema elementFormDefault="qualified" targetNamespace="http://test.com" xmlns="http://www.w3.org/2001/XMLSchema">
<element name="celsiusToFarenheit">
<complexType>
<sequence>
<element name="temp" type="xsd:decimal"/>
</sequence>
</complexType>
</element>
<element name="celsiusToFarenheitResponse">
<complexType>
<sequence>
<element name="celsiusToFarenheitReturn" type="xsd:decimal"/>
</sequence>
</complexType>
</element>
<element name="farenheitToCelsius">
<complexType>
<sequence>
<element name="temp" type="xsd:decimal"/>
</sequence>
</complexType>
</element>
<element name="farenheitToCelsiusResponse">
<complexType>
<sequence>
<element name="farenheitToCelsiusReturn" type="xsd:decimal"/>
</sequence>
</complexType>
</element>
</schema>
</wsdl:types>

<wsdl:message name="farenheitToCelsiusResponse">

<wsdl:part element="impl:farenheitToCelsiusResponse" name="parameters">

</wsdl:part>

</wsdl:message>

<wsdl:message name="farenheitToCelsiusRequest">

<wsdl:part element="impl:farenheitToCelsius" name="parameters">

</wsdl:part>

</wsdl:message>

<wsdl:message name="celsiusToFarenheitRequest">

<wsdl:part element="impl:celsiusToFarenheit" name="parameters">

</wsdl:part>

</wsdl:message>

<wsdl:message name="celsiusToFarenheitResponse">

<wsdl:part element="impl:celsiusToFarenheitResponse" name="parameters">

</wsdl:part>

</wsdl:message>

<wsdl:portType name="TestWS">

<wsdl:operation name="celsiusToFarenheit">

<wsdl:input message="impl:celsiusToFarenheitRequest" name="celsiusToFarenheitRequest">

</wsdl:input>

<wsdl:output message="impl:celsiusToFarenheitResponse" name="celsiusToFarenheitResponse">

</wsdl:output>

</wsdl:operation>

<wsdl:operation name="farenheitToCelsius">

<wsdl:input message="impl:farenheitToCelsiusRequest" name="farenheitToCelsiusRequest">

</wsdl:input>

<wsdl:output message="impl:farenheitToCelsiusResponse" name="farenheitToCelsiusResponse">

</wsdl:output>

</wsdl:operation>

</wsdl:portType>

<wsdl:binding name="TestWSSoapBinding" type="impl:TestWS">

<wsdlsoap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"/>

<wsdl:operation name="celsiusToFarenheit">

<wsdlsoap:operation soapAction=""/>

<wsdl:input name="celsiusToFarenheitRequest">

<wsdlsoap:body use="literal"/>

</wsdl:input>

<wsdl:output name="celsiusToFarenheitResponse">

<wsdlsoap:body use="literal"/>

</wsdl:output>

</wsdl:operation>

<wsdl:operation name="farenheitToCelsius">

<wsdlsoap:operation soapAction=""/>

<wsdl:input name="farenheitToCelsiusRequest">

<wsdlsoap:body use="literal"/>

</wsdl:input>

<wsdl:output name="farenheitToCelsiusResponse">

<wsdlsoap:body use="literal"/>

</wsdl:output>

</wsdl:operation>

</wsdl:binding>

<wsdl:service name="TestWSService">

<wsdl:port binding="impl:TestWSSoapBinding" name="TestWS">

<wsdlsoap:address location="http://localhost:8081/WebServices/services/TestWS"/>

</wsdl:port>

</wsdl:service>

</wsdl:definitions>

</code>
 
Beware the other head of science - it bites! Nibble on this message:
the value of filler advertising in 2021
https://coderanch.com/t/730886/filler-advertising
reply
    Bookmark Topic Watch Topic
  • New Topic