POST /BasicFunctions.asmx HTTP/1.1 Host: 203.122.51.66 Content-Type: text/xml; charset=utf-8 Content-Length: length SOAPAction: "http://tempuri.org/FetchAllEmpDetails" <?xml version="1.0" encoding="utf-8"?> <soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"> <soap:Body> <FetchAllEmpDetails xmlns="http://tempuri.org/" /> </soap:Body> </soap:Envelope>
public int GetSum(string a, string b)
{
return Convert.ToInt32(a) + Convert.ToInt32(b);
}
[ServiceContract]
public interface ICalculationService
{
[OperationContract]
[WebInvoke(Method = "GET", ResponseFormat = WebMessageFormat.Json, BodyStyle = WebMessageBodyStyle.Wrapped, UriTemplate = "GetSum?a={a}&b={b}")]
int GetSum(string a, string b);
}
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<system.web>
<compilation debug="true" targetFramework="4.0" />
</system.web>
<system.serviceModel>
<services>
<service name="CalculationService.CalculationService" behaviorConfiguration="ServiceBehaviour">
<endpoint address="" binding="webHttpBinding" contract="CalculationService.ICalculationService" behaviorConfiguration="web" />
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior name="ServiceBehaviour">
<serviceMetadata httpGetEnabled="true"/>
<serviceDebug includeExceptionDetailInFaults="false"/>
</behavior>
</serviceBehaviors>
<endpointBehaviors>
<behavior name="web">
<webHttp/>
</behavior>
</endpointBehaviors>
</behaviors>
<serviceHostingEnvironment multipleSiteBindingsEnabled="true" />
</system.serviceModel>
<system.webServer>
<modules runAllManagedModulesForAllRequests="true"/>
</system.webServer>
</configuration>
protected void onMain_BtnCalculateAction(final Component c, ActionEvent event)
{
super.onMain_BtnCalculateAction(c, event);
ConnectionRequest r = new ConnectionRequest()
{
Hashtable h;
@Override
protected void postResponse()
{
findTxtResult(c).setText(h.get("GetSumResult").toString());
}
@Override
protected void readResponse(InputStream input) throws IOException
{
JSONParser p = new JSONParser();
h = p.parse(new InputStreamReader(input));
String result = h.get("GetSumResult").toString();
}
};
r.setUrl("http://localhost:52581/CalculationService.svc/GetSum");
r.setPost(false);
String value1 = findTxtValue1().getText();
String value2 = findTxtValue2().getText();
r.addArgument("a", value1);
r.addArgument("b", value2);
InfiniteProgress progress = new InfiniteProgress();
Dialog dlg = progress.showInifiniteBlocking();
r.setDisposeOnCompletion(dlg);
NetworkManager.getInstance().addToQueue(r);
}