Bug 13942 - Problem in Consuming WCF Services in Mono for Android Mobile Application
Summary: Problem in Consuming WCF Services in Mono for Android Mobile Application
Status: RESOLVED NOT_ON_ROADMAP
Alias: None
Product: Android
Classification: Xamarin
Component: General ()
Version: 4.2.x
Hardware: PC Windows
: --- normal
Target Milestone: ---
Assignee: Jonathan Pryor
URL:
Depends on:
Blocks:
 
Reported: 2013-08-13 04:11 UTC by Sreeni
Modified: 2013-08-23 12:00 UTC (History)
1 user (show)

Tags:
Is this bug a regression?: ---
Last known good build:

Notice (2018-05-24): bugzilla.xamarin.com is now in read-only mode.

Please join us on Visual Studio Developer Community and in the Xamarin and Mono organizations on GitHub to continue tracking issues. Bugzilla will remain available for reference in read-only mode. We will continue to work on open Bugzilla bugs, copy them to the new locations as needed for follow-up, and add the new items under Related Links.

Our sincere thanks to everyone who has contributed on this bug tracker over the years. Thanks also for your understanding as we make these adjustments and improvements for the future.


Please create a new report on Developer Community or GitHub with your current version information, steps to reproduce, and relevant error messages or log files if you are hitting an issue that looks similar to this resolved bug and you do not yet see a matching new report.

Related Links:
Status:
RESOLVED NOT_ON_ROADMAP

Description Sreeni 2013-08-13 04:11:38 UTC
Hi,
 
I am working on Mono Android Mobile Applicaiton, I have problem while consuming WCF Services in my mobile application. How can i get ServiceClient in the application in order give the Binding type and Endpoint

How to specify **Endpoint **and how to get **ServicClient **in MonoAndroid Mobile Application?


In normal .Net Client(dotnet web application) when we add Service to the client we will get ServiceClient automatically

In DotNet Client We will get

WebService.GPFServerService.GPFServerClient oCls;
 BasicHttpBinding bGPFBinding = new BasicHttpBinding("BasicHttpBinding");
 string sEPAddress = System.Configuration.ConfigurationManager.AppSettings.Get("GPFServerService_EndPoint"); 
EndpointAddress ep = new EndpointAddress(sEPAddress);

oCls = new WebService.GPFServerService.GPFServerClient(bGPFBinding, ep);
textbox1.text = oCls.GetAllCountries(); _

Where as in Mono Android I am getting

WebService.GPFServerService oCls = new WebService.GPFServerService(); 
textbox1.text = oCls.GetAllCountries();

and there is no ServiceClient to give the Binding and Endpoint. But i am getting all the Operation Contracts.

We don't have config files in MonoAndroid Application i hope.....

Note:
--------------------------------------------------------------------------------------------------------------------------------------
When i am calling the services with the above code on device i am getting "Name Resolution Error". I posted this on Xmarian Forum with "System.Net.WebException" as Question. 
---------------------------------------------------------------------------------------------------------------------------------------


Note:- 
 I found this url http://docs.xamarin.com/guides/cross-platform/application_fundamentals/introduction_to_web_services  and follwed SubHeading 4.Consuming WCF Services..

I got GPFService.cs and ServiceReferences.ClientConfig files by which i can get ServiceClient ,But by this i am able to call the operationcontracts in Async mode only. i.e

GPFServiceClient ogpfClient = new GPFServiceClient(); ogpfClient.GetAllCountriesAsync(); ogpfClient.GetAllCountriesCompleted += new EventHandler(ogpfclient_GetAllCountriesCompleted);

As per requirement I need to call services Synchronously. So is there any way how to get the ServiceClient and how could i specify the endpointaddress and binding in order to call the services synchronously.

Please help me out, It's urgent requirement.

Thanks in Advance

Sreeni
Comment 1 Jonathan Pryor 2013-08-14 16:58:53 UTC
Our WCF binding is based on the Silverlight pattern, which only supports async calls.

This is By Design.

If you need synchronous behavior, you will need to build it yourself atop the async infrastructure.
Comment 2 Sreeni 2013-08-23 12:00:16 UTC
 
 Firstly, Thanks for your reply.

I have another issue I tried using the services Asynchronously. Here is my Problem.

Q 1)
Why SilverLight Tool won't generate Service related ServiceClient?

Description:

Using SilverLight Tool. I tried getting Proxy Class and Config Files

I ran the follwing command in command prompt:

 C:\Program Files\Microsoft SDKs\Silverlight\v4.0\Tools>SlSVcUtil.exe http://192.168.4.800/GPFWebServices-GPFDEV/AdminService1.svc/ /directory:"c:\Documents\MyFolder"

I got proxy class with the service name "AdminService1.cs" and ServiceRefernce.ClientConfig files.

After Adding the files to my client application.
--------------------------------------
In "AdminService1.cs" (Proxy file)
-----------------------------------
namespace Gold.GPFWebServices
{
    using System.Runtime.Serialization;
        
    [System.Diagnostics.DebuggerStepThroughAttribute()]
    [System.CodeDom.Compiler.GeneratedCodeAttribute("System.Runtime.Serialization", "4.0.0.0")]
    [System.Runtime.Serialization.DataContractAttribute(Name="WebServicesClient", Namespace="http://schemas.datacontract.org/2004/07/Gold.GPFWebServices")]

public partial class WebServicesClient : object
{
 private string _userNameField;

 public string UName
        {
            get
            {
                return this._userNameField;
            }
            set
            {
                this._userNameField = value;
            }
        }}
}
and ClientConfig File with 
<configuration>
    <system.serviceModel>
        <bindings>
         <basicHttpBinding>
            <binding name="BasicHttpBinding_IAdminService1"     maxBufferSize="2147483647"
               maxReceivedMessageSize="2147483647">
                    <security mode="None" />
                </binding>
   </basicHttpBinding>
        </bindings>
 <client>
            <endpoint address="http://192.168.4.800/GSPWebServices-GSPDEV/AdminService.svc/AdminService1"
                binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_IAdminService1"
                contract="IAdminService" name="BasicHttpBinding_IAdminService" />
 </client>
</configuration>
     

-----------------------------------------------------
I followed the same procedure to generate Proxy for another service(i.e GPFService)I got the same Client Proxy in the GPFService.cs File like ABOVE
and ServiceReferences.ClientConfig File.

ServiceRefernce.ClientConfig file contains the info related the GPFService binding and endpoint adress info....

Problem is with the Proxy Class which i am getting..

Actually i need to get
Gold.GPFWebServices.AdminServiceClient.WebServiceClient  
and 
Gold.GPFWebServices.GPFServiceClient.WebServiceClient.

But why it's getting only Gold.GPFWebServices.WebServiceClient ? 

This is causing Ambiguity Error with the properites when i tried to add another service (for eg:GPFService) to my Client Application in which also having the same Properties (like UName,etc ..etc), By this i am limited to use only one service at time.

ServicRefernce.ClientConfig 
And One More Question:

Q 2).
How can i generate Proxy Client to all Services at a time with one ServiceRefernce.ClientConfig file, in which i contains all the services binding and endpoint information.

What's the wrong i am doing. Is there any other way to fix the problem. I am looking for response. If any sample applications provided will be appreciated.


Thanks in Advance.
Sreeni