Xamarin Forms, using WCF Service Error - c#

Currently I have Xamarin.Forms application which use service reference WCF, SellerCloud API which is on "http://ws.timezone123.com/SCService.asmx".
Referencing SCService I receive two compile exceptions
"The type or namespace name 'XmlElement' does not exist in the namespace 'System.Xml' (are you missing an assembly reference?)" and "The type or namespace name 'schema' could not be found (are you missing a using directive or an assembly reference?)".
http://prntscr.com/g5sgf1
Currently library, from which I am trying to reference service is Portal Class Library with Target Framework "Profile7".
Can you suggest what I can do in that case to make it work?
Thanks

How did you add the service reference to PCL?
You are trying to consume ASMX web service( XML web service with SOAP protocol). As i can see your screenshot ,you added a connected service (typically used for azure app services) not a Web reference. In order to consume ASMX service you need to add a Web reference.
Problem is, web reference is not available in PCL .But it is available in platform specific projects(right click the droid or Ios project --->Add--->Web Reference).
If you add web reference correctly it will generate proxies within your platform specif projects.Then you need to access generated web methods through Dependency service in your PCL.Please check following documentation for further idea
https://developer.xamarin.com/guides/cross-platform/application_fundamentals/web_services/#asmx
Following question is some what similar to your problem
Is there any supported way to call asmx web services from cross-platform Xamarin code?

Related

How to consume a library with web services in it without having to define the endpoints in the consuming application's config file (e.g. app.config)?

I'm trying to develop a C# library that will be consumed in multiple C# based applications (e.g. WPF and ASP.NET projects), using the .NET framework.
My library depends on a specific web service (SOAP) which isn't necessarily in the consuming applications that will be using my library.
Is it any way possible for those applications to use my library without having to define the endpoints of the web services in my referenced library in its config file?
If not, how do "enterprise" type libraries solve this problem?...is this just a limitation of libraries?
Note, the error encountered when one doesn't define the matching endpoints in the consuming application is: "Could not find default endpoint element that references contract 'Web Service Contract Name' in the ServiceModel client configuration section. This might be because no configuaration file was found for your application or because no endpoint element matching this contract could be found in the client element."

Calling a Webservice from a C# Class Library

I have created a class library - MyNS.MyClass. The Library has a Service Reference to a Webservice (added through Add Service Reference) - the Service Reference shows up as MyNS.VS in the Project. The class library is MyNS.dll. MyClass has a static method myStaticFunc which calls the Web Service
I have a separate C# console application where I add reference to this DLL. I have code there calling MyNS.MyClass.myStaticFunc. My project compiles fine. But when I run it, I get an exception
{"Could not find default endpoint element that references contract
'VS.MyObj' in the ServiceModel client configuration section. This
might be because no configuration file was found for your application,
or because no endpoint element matching this contract could be found
in the client element."}
To get rid of this exception, I have to also add a Service Reference in my Console Application & give it the same name (VS - however, here the namespace would obviously be my client app's namespace).
I don't understand why this needs to be done - it's the Library which is calling the WebService - the app is not calling it directly - and the Library does have the Service Reference. And why does the workaround work - in spite of the namespaces being different?

Can't find namespace in Global

I have the job of getting a legacy project working again. This project was done many years ago using Silverlight and C# Class Library's.
The error I am getting is to do with a namespace inside the project file called Silverlight.Business:
Code
using Tcx = global::MapTools.Xml;
Error:
The type or namespace name "MapTools" could not be found in the global namespace (are you missing an assembly reference?)
MapTools is a C# Class Library and Silverlight.Business is a Silverlight Library. Due to this I can't add a reference to MapTools inside the Silverlight project file.
The silverlight project does have a WCF RIA Service's Link but that does not connect to anything.
I am now wondering how the person that wrote the code has managed to call that namespace? I have tried researching how to add the MapTools.dll to the Global namespace but have not found anything.
Anyone have any ideas?
To do that there should be an some tool been used .
We had used in our projects a Portable library which allowed us to communicate through cross type of projects , below is the link :
https://msdn.microsoft.com/library/gg597391(v=vs.100).aspx

silverlight Application can not use wcf namespace

I have a Silverlight application with a web application to test it,
there are two WCF services I created on my web application.
I can add reference all my services in my Silverlight application but when I want to use one of my data contracts ,I can not add my service namespace to the Silverlight application:
ex: I have a person class in my WCF service(reference name)
WCF service.person = new wcfservice.person();
Error:
The type or namespace name 'WCF service' could not be found (are you
missing a using directive or an assembly reference?)
I can add reference all my services in my Silverlight application but
when I want to use one of my data contracts...
You can't bring in the namespace because it exists in an assembly which has been complied in a different CLR. But that doesn't mean one can't work with the defined class. By bringing the target class(es) into the Silverlight project via the use of a linked file one can safely work around the CLR differences.
A linked file is built in both projects, the original and the linked, but only resides in one location; hence changes made to it are reflected in both projects.
In the Silverlight project add the target file(s) and then choose:
That way you can use the class within the namespace as such, for it is compiled into the Siliverlight programs scope; but any changes made to the file are also reflected in the Silverlight app.

How to invoke or start an asp.net web service (asmx) from another project in C#

How do I invoke or start a asp.net web service (asmx) from another project in C#. The another project can be a console application. I am not asking to consume the web service (which I am doing in Java) but how to start the web service in C# but from a different project.
I already tried including the webservice project in my console application project and also added a reference to the webservice project, included the namespace but I get an error,
The type 'System.Web.Services.WebService' is defined in an assembly that is not referenced. You must add a reference to assembly 'System.Web.Services, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'.
I am trying to invoke the webservice by creating an instant of the webservice class which I guess is already a wrong way.
Thanks in advance!
You are going to want to add a web reference.
How to: Add a Reference to a Web Service
Then you are going to want to set multiple projects to start. This will allow you to debug both.
How to: Set Multiple Startup Projects

Categories

Resources