Using PHP nuSOAP webservice in C# - c#

I am working on windows phone project in visual studio 2012 for windows phone.
I am trying use PHP NuSOAP webservice by adding Service reference.
Here I followed this sample app. In general the VS will create Reference.cs file while adding webservice. You can see reference.cs file contents of dictionary(Sample) app HERE
The Reference.cs of my webservice of my project HERE. In my Reference.cs file the interface SomeMobileServicePortType is empty.
In Line 19.
public interface SomeMobileServicePortType {
}
Because of this I not getting any methods of webservice to access in my project. But while adding reference in Add service Refernce dialogue it is showing the methods contains in PHP NuSOAP webservice.
I created new instance of webservice class..
ServiceReference1.SomeMobileServicePortTypeClient client = new ServiceReference1.SomeMobileServicePortTypeClient();
What is the wrong with PHP webservice. I tried some more webservices [in particular asmx, I didn't get any sample PHP NuSOAP webservice to try] which are working fine. Can any one tell me How to use PHP NuSOAP service using C#.
==================================================================================
Edit:
We are using NuSOAP PHP webservice.
I believe that there is no problem with Webservice. I can't share the WSDL file right now.
Here I got the sample that explains using PHP NuSOAP in C#. I tried with this webservice link. This reference also not giving any methods. The interface is empty like this.
public interface HirdWebExamplePortType { }
So my guess is while using NuSOAP service it is not working in IDE Visual Studio.
Here is my sample windows phone project. Please try this & suggest me what I am doing wrong.

The project you supplied is not compatible with this kind of SOAP-Service.
If you add the service to e.g. a Console App it works fine:
but if you add it to your project (WP Silverlight):
Check if you can disable SOAP encoding on your service.

It does support RPC/Literal soap style so we need to change the style from RPC/encoded to RPC/literal. This is actually really easy: Open the wsdl file and modify the input and output operations from
<soap:body use="encoded" ..../>
to
<soap:body use="literal" ..../>
Reference:
Just go through the below link:
http://guruce.com/blogpost/hosting-webservices-on-wec-using-gsoap-windows-phone-75-mango-client-application#comments

Related

consume php soap webservice in winform c#

one of my friend made a soap webservice in PHP and now i have to consume it into my winform app. I added web Service Reference , pasted the URL and it is showing method name.
The method name is Display().
Now after adding when write code on button click, it is showing following three methods:
MyWebServiceName. DisplayCompletedEventArgs
DisplayCompletedEventHandler
SiteControllerService
There is no soapClient or direct Display method ,any one know , what am I doing wrong?
Check the WSDLyou must have in the VS project. You will find the service name:
Ex:
<wsdl:service name="SiteControllerService">
So you must type:
MyWebServiceName.SiteControllerService SOAPclient = new MyWebServiceName.SiteControllerService();
SOAPClient.Display();
Visual Strudio create a namespace to encapsulate all classes generated to work with the web service. In that namespace you will find the soap proxy client, events and events handler and any data transfer object needed to pass parameters to proxy client or to recive the response.

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!

Using a WebService From Another Project in my own project in 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.

I am trying to consume a PHP SOAP service from C# and create a class wrapper in VS 2010

I've been tasked with creating a class wrapper for a SOAP service, the idea is that you'll be able to treat it as a regular class. The main reason for this is that the WDSL for the SOAP service contains only one method and it's got 5 parameters and it's only kind of OO so you'd have to know all the method calls really well and it's a bit hard to remember them all.
OK, so I've tried adding a web reference, now web references can now be added as service references in VS 2010. You click add service reference advanced etc and it puts in a service reference. Great. Unfortunately if I try and access this from a class I can't.
I can build a console app and put code in the main procedure and access the method of the SOAP service fine but when I add a reference to a class library the intellisense won't allow me to select anything. I'd instantiate an instance like so:
SOAPService.webServiceService ws = new SOAPService.webserviceService();
ws.
and then the intellisense refuses to kick in. If I do the same in a web project or a console app then I can access it fine. I've added the namespace I've done all kinds of things. Also, I can add a web reference and get a DISCO file whenever I create a web project.
OK, also while I'm on the subject I also need to pass credentials to the web service in PHP.
The problem is that in the past I'd create some .net system credentials and add these and it would usually pass through if I was connecting to another .net service.
How should I be sending them to a PHP web service? I always get either invalid username/password combo errors or envelope malformatted error types
Thanks
Mr. B
So the intellisense is not working, but if you add the method in and try to use it does it work, or produce an error?
With regard to diagnosing authentication issues try using fiddler to view the SOAP messages that are being sent, and to view the reply. Do you have some other software that connects and authenticates to that service? Use fiddler to look at the SOAP messages and compare them to see if the header is different etc.
I'd normally do it like this,
using (Service service = new Service())
{
service.ClientCredentials.Windows.ClientCredential.Domain = "domain";
service.ClientCredentials.Windows.ClientCredential.Password = "password";
service.ClientCredentials.Windows.ClientCredential.UserName = "username";
}
Also with regard to the service working or not in general use fiddler if you have any problems, you can see the SOAP messages and it often gives you a clearer message.
I know in IIS you can turn on failed request handling that also gives you an insight from what is going on at the server end, perhaps you have some form of logging too for your php service?

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