Using a WebService From Another Project in my own project in C# - c#

Hello i'm trying to add a webservice to my project, and that web service is from another project i have open. IIS is set up and everything works good with the webService.
Ok so on first image ,im using the webservice in the same project i have it created and it works fine
http://img215.imageshack.us/img215/4605/55347669.jpg
On second image i add the webreference and it is added succesfully . Thing is i dont know how to access it ( the HelloWorld function that returns a string which i want to set up to be text for the label )
http://img846.imageshack.us/img846/4922/19350256.jpg
The error i get at the second image says
" BankarskiUslugi is a namespace but it is used as type."
So i would appreciate any help if someone tells me how can i 'call' the webservice in my proect.
Thanks a lot in advance !

When you added the web service reference, it should have shown a namespace for the web service you were referencing; you need to add something like:
using YourWebServiceNamespace;
And then you should be able to instantiate it and call the methods as you are trying to do on the second image.

Alternatively, you can use WCF Test Client (WcfTestClient.exe) as far as testing is concern.

See How to Consume a Web Service.

Related

Adding a Web Service for ReportExecution2005 - Resource cannot be found C#

I'm trying to add the ReportExecution2005 Web Service into my project to allow me to execute reports from within my program.
We do this in other programs that are written in VB.net however, these programs have a namespace added for ReportingService that's around 3000 lines of code as the company has always struggled with adding the ReportExecution web service. Before I begin converting this code from VB.net to C# I thought I'd try again in getting it working the proper way.
I'm currently going to the Add Web Reference page, and putting the following:
http://reportserver/Reports/ReportExecution2005.asmx
This is returning a 404 error saying the resource can't be found. I've checked the URL over and over and got colleagues too. So I'm not really sure what else the issue could be.
Is there something that needs adding onto our report server for me to be able to add the web reference?
If anyone has had this issue before how did you solve it?
Any tips appreciated.

Consuming multiple WCF services from a single client

I have hosted two WCF services using a console application, one on port 8080 and the other at port 8090. I am able to create object for the first service named AccountManagementService but not for the other service named UserRegistrationService.
Snapshot below shows that two services have been added.
The second service doesn't show up in intellisense at all.
The complete details of the service used can be found at the following link(this is also a question asked by me):
Hosting two WCF services using a single console app
I have tried multiple times deleting and creating new service but nothing seems to be working. Please suggest.
based on the image, it should be there. open the reference.cs file for the service that is not showing up in IntelliSense and check the namespace. Then Try creating the reference using the full name. to get to the reference.cs file, click on Show all files in solution explorer as shown below
for example, if in reference.cs, you see the namespace WWWCF.UserRegistration as foo.bar.WWWCF.UserRegistration, then create instance using
foo.bar.WWWCF.UserRegistration ref = new foo.bar.WWWCF.UserRegistration ();
Found the solution. Not sure I understand the reason, though. But the following link has answers to my issue and has solved it.
Empty Reference.cs file issue solved

How I set a reference to a SOAP file and use this functions in C#

I want create a ASP.NET Application (aspx site) that connection with a database and create userconnections for the internet. I get a Soap Data (soapapi.wsdl). This file have all function for create a guestuser or get Informations about who apply a GuestUser and the Time.
My Problem is that I don't know how I can add a reference to this Soap File in C# an execute this functions :( ? I search it but I don't found a good example :/
What I need for a Namespace and how i set a reference to this wsdl file ?
tarasov
Try to add Service Reference
Right click on project file ->Add Service Reference. In the dialog point to this wsdl file.
At result a proxy c# class will be generated, that allows you to call soap methods as usual code

Magento Go C# requesting API fails to initialize

I am trying to connect to Magento API using C#. I am using Magento Go service and from what I've read I am able to use their API - I hope I am not wrong here. So here is what I did:
I added a Service Reference to http://mydomain.gostorego.com/api/v2_soap?wsdl=1, and just adding a service worked fine. Now I created a test class with GetStuff() method, which looks like this:
using ww.Feeds.MagnetoGoService;
public static string GetStuff()
{
MagnetoGoService.Mage_Api_Model_Server_V2_HandlerPortTypeClient s = new MagnetoGoService.Mage_Api_Model_Server_V2_HandlerPortTypeClient();
var login = s.login("username here", "key here");
return login.ToString();
}
When I run the program I get an error in first line saying:
Could not find default endpoint element that references contract 'MagnetoGoService.Mage_Api_Model_Server_V2_HandlerPortType' 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.
Any ideas what this may be? Do I have to set something up in my Magento Go settings? Or maybe using Magento Go is not allowing API access?
Thanks a lot.
Forget SOAP with c# you will pull your hair out. Download Charls Cook's xml-rpc api libary for c# and use the xml-rpc method. You won't get all the snazzy intellisense but at least it will work. There's also c# solution from ez.newsletter they released with Cook's library demonstrating how to use 80% of the magento api calls.
Cook's library xml-rpc.net
http://www.xml-rpc.net/
ez.newsletter solution
http://code.google.com/p/csharlibformagexmlrpcapi/
If anyone ever has problems with this, my solution was this:
I used the reference in one project, but I actually called the class and had main program in another project. You need your Service reference to be in each project wherever you're using it. That fixed it! Alternatively you can create a new BasicHttpBinding() and putt all the options from app.config/web.config into that binder, then you don't need to reference to Service everywhere. I hope that helps!

c# client application can't consume tomtom connect webservice

I have to write a windows application in c# which application is able to consume said webservice.
I am using VS2010 with .Net 4
I added the service reference and the code compiles without any error, but when i run it i get a ProtocolException with the text:
The content type "multipart/related; type="application/xop+xml";
boundary="----=_Part_0_159582014.1283501395804";
start="";
start-info="application/soap+xml"" of the response does not match the
binding (application/soap+xml; charset=utf-8)
When i try it with a VB sample provided by the developers of the webservice everything works fine.
Im totally lost here, googled since yesterday, came up with nothing... Anyone knows whats the problem there?
Ok finally figured it out.
You need to manually edit the app.config file of your application and change all occurences of "textMessageEncoding" to "motmMessageEncoding" that will do the trick
no motmMessageEncoding -> mtomMessageEncoding
you need to make sure that your application supports MTOM. This
requires a change to your app.config. More details can be found here:
http://www.tomtomwork.com/en/webfleet/connect/blog.xml - scroll down
to the section "Updated Visual Basic example now uses SOAP, too"
Try adding a Web Reference rather than a Service Reference and see if that makes any difference. When you select Add Service Reference, click "Advanced..." then "Add Web Reference..." to bring up the old style reference screen.

Categories

Resources