Web Services Developer Community Search Web Site
 
Web Services
AcademicLicenseService
AcademicVerifier
AirportWeather
AmazonSearchService
FOPService
GlobalWeather
CapeMail
PolyCalc
ReservationAgent
Schema-2-WSDL
WSDL Transformer
 
>
Home: Web Services: Calculating the Area of a Polygon

PolyCalc

Introduction

This web service calculates the area of a polygon based on a provided sequence of co-ordinates, demonstrating complex type handling. The calculation, based on Green's Theorem, requires a sequence of co-ordinates, ordered according to a right hand traversal of the polygons vertices. Co-ordinates are provided as (x,y) pairs with x and y being of type float.


Web Service Technical Details

 
Name of Service: PolyCalcApp
SOAP Endpoint URL: http://live.capescience.com/ccx/PolyCalcApp
SOAPAction:
Method Namespace URI: http://www.capeclear.com/PolyCalcApp.xsd
Method Name(s): calculate
WSDL URL: http://live.capescience.com/wsdl/PolyCalcApp.wsdl
Server: CapeConnect 3.5
Contact: Visit our forum


Sample SOAP Messages SOAP Request
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"
             xmlns:CCNS="http://www.capeclear.com/attributes/"
             xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
             xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/"
             xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<SOAP-ENV:Body>
    <ns1:calculate xmlns:ns1="capeconnect:PolyCalcApp:PolyCalc"
          SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
          <coords xsi:type="SOAP-ENC:Array"
          SOAP-ENC:arrayType="SOAP-ENC:Struct[3]">
          
          <item xsi:type="SOAP-ENC:Struct">
                <x xsi:type="xsd:float">0.0</x>
				<y xsi:type="xsd:float">0.0</y>
          </item>
          
          <item xsi:type="SOAP-ENC:Struct">
          <x xsi:type="xsd:float">0.0</x>
		  <y xsi:type="xsd:float">2.0</y>
          </item>

          <item xsi:type="SOAP-ENC:Struct">
          <x xsi:type="xsd:float">2.0</x>
		  <y xsi:type="xsd:float">2.0</y>
          </item>       
          
          </coords>
      
    </ns1:calculate>
      
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>              
                        
SOAP Reply
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"
             xmlns:CCNS="http://www.capeclear.com/attributes/"
             xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
             xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/"
             xmlns:xsd="http://www.w3.org/2001/XMLSchema">
                      
<SOAP-ENV:Body>

    <ns1:calculateResponse xmlns:ns1="capeconnect:PolyCalcApp:PolyCalc"
             SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
                              
        <return xsi:type="xsd:float">2.0</return>

    </ns1:calculateResponse>

</SOAP-ENV:Body>
</SOAP-ENV:Envelope>


Client Sample Code

The SOAPDirect toolkit, provided as part of CapeConnect provides an ease-of-use layer above SOAP/HTTP. Sample code based on a SOAPDirect Java client is shown below:

// Create Request
SDUri targetURI = SDUtils.toTargetURI("PolyCalcApp", "PolyCalc", "calculate");
SDRequest request = new SDRequest(targetURI);

SDComplexType[] coords = new SDComplexType[3];

coords[0] = new SDComplexType();
coords[0].add("x",0.0F);
coords[0].add("y",0.0F);

coords[1] = new SDComplexType();
coords[1].add("x",0.0F);
coords[1].add("y",2.0F);

coords[2] = new SDComplexType();
coords[2].add("x",2.0F);
coords[2].add("y",2.0F);

request.add("coords",coords);

// Dispatch
SDReply reply = request.invoke("http://www.capescience.com:80/ccgw/GWXmlServlet");

if (reply.isFault())
{
    SDFault fault = reply.getFault();
    System.out.println("SOAP Fault: " + 
        fault.getFaultActor() + "," + 
        fault.getFaultCode() + "," + 
        fault.getFaultString() );    
}

System.out.println("area is " + reply.getFloat());
 
Help / Support?
Having problems with PolyCalc? Visit our forum.
  webmaster@capescience.com · Trademarks · Terms of Use