How to add vb webservice in C# project - c#

Hi i am new to C# web services,
I need a clarification. In my company , i was given a webservice url (http://servicename/psWs/psWs.asmx) and the methods in this service are writtn in VB.net . But my problem is , i know only C# and i am a beginner in C# , is there a way to create C# Web Service or WCF and call the service reference url in VSTS where the web service url methods is written in VB .net. Can u please help to any solution . Your help is more valuable.
Finally what i am trying to achieve is ,
1.create a wcf C# application or asp.net web application
2.Add the reference url (http://servicename/psWs/psWs.asmx) where the methods is written in VB.net
3.Test the web service by giving input and validating the output
Please dont downvote if my question is irrelavant.

Just right click the project (in which you want to add web service reference) and add the web service reference. Language doesn't matters here. From MSDN
To add a Web reference to a project In Solution Explorer,
right-click the name of the project that you want to add the service
to, and then click Add Service Reference. The Add Service Reference
dialog box appears.
In the Add Service Reference dialog box, click
the Advanced button. The Service Reference Settings dialog box
appears.
In the Service Reference Settings dialog box, click Add Web
Reference. The Add Web Reference dialog box appears.
In the URL box,
enter the URL of the Web service to use. If you do not know the URL,
use the links in the browse pane to locate the Web service you want.
In the Web services found at this URL box, select the Web service to use.

Related

How to reference a Web Service from an ASP.NET MVC project?

I want to add a web service to my ASP.NET MVC 5 project.
I do that by right click on the project in solution explorer > add > service reference.
Then I add a web service url like this and it creates a new file in Service References folder called ServiceReference1
Then I'm able to call web service methods in C# by using ServiceReference1 namespace and VS intellisense works.
The problem is that when I add this web service url, it adds a new namespace (ServiceReference2) to that folder, but I can't call the new namespace and it says ServiceReference2 namespace could not be found.
Is it me doing something wrong or the web service has a problem?
After you open your service window, click on the advanced button like below.
In general, I agree it's best not to use the older versions of web-services like I'm showing here, but in real life people have deadlines and such.
Saying that though, there is no huge drawback to using this tech, as long as performance isn't an issue.
Then, click 'add Web Reference' like the picture below.
Then enter URL and click on the little arrow button. Name your reference and click 'Add Reference'. see pic below

How to add web service (ASMX) refernece dynamically in C# (not to do "Add web Refernece" )

How to add webservice reference dynamically ?
I have created a class library project and i need to post data into a web service.
I don't want to consume web service as "Add Web reference" as i dont' want to use APP.CONFIG file and need to load this web service dynamically.
Please suggest me how dynamically i could load this web service inside this class library project ?
pLEASE share some code if possible.
Thank You
If you want to dynamically support different types of web services, they'll have to use an consistent interface so that a single set of classes can use the web services. Which will result in building a separate library.
Adding a Web reference dynamically at Runtime

No discovery information when use php webservice with C#

I got some critical problem when I just try to use php web service with C# windows form application..
My Problem is that Normally when I want to add web reference in my local pc and the web service is running in asp.net
I can add the web reference and work with It but when I try to add a web reference whic is build in php I got thid error....
Add reference button is inactive and...
Show the message....
The HTML document does not contain Web service discovery information.
It shows all methods of my php webservice ...
But what can I do now...
Please Help any One...

Use a Web Service in C# Windows App

I am new to using web services. I am assigned a task in which I need to use a web service in my Windows app. This is the web service I would be using:
https://api.betfair.com/global/v3/BFGlobalService.wsdl
Now, I've learned how to add a web reference to this service, but I could not find a basic tutorial that could help me learn how to make an object of this web service and use the service as I want to.
Basicaly, what I need is to create an object from the above web service in my form, and to call it's methods. A C# code snippet would be great.
Can anyone give me some directions? I am working in Visual Studio 2008 and a C# Windows App.
Right click on References
select Add Service Reference
give the wsdl address in the address textbox
click Discover
Give a name for the namespace eg;- BFG
You can access the resources like BFG.MethodName() from you code

Consume web service in asp.net app from a class library

My team and I have a asp.net web forms application and are using several class libraries. In one of those libraries, we are trying to consume a web service. The web reference was added in the web app project and the appropriate references have been added. The app compiles. When attempting to consume said web service in the class library, the credentials don't seem to work, and the call fails. However, if we take the web service call out of the class library, and consume it within the web app, it works.
Any ideas why this is not working in the class library.
Double check your configuration file includes the correct information for the Web service.
Try changing the URL behavior to dynamic as well.
Also, as John stated, I'm assuming you're adding the service to the class library because you intend to use it from the library, as opposed to other areas of the Web application.
"the credentials don't seem to work, and the call fails"...can you give a small stack trace of the error?
Just to clarify, in my current project, we use WCF endpoints within a class library with bindings and credentials. The same can be done for a SOAP ASMX Web reference as you're attempting.
You can add a web service reference by doing the following steps:
right click on the project on the Solution Explorer
click Add Service Reference
click Advanced
you will find "Add Web Reference" at the end of the form
If you are adding the reference in application and then consuming it from class library... How you call the class library.. by adding reference and invoking the method of class library and then how you are accessing proxy from the class library you need to reference it... It seems to me a circular reference. Which shouldn't be compiled at first place... Are you describing your structure correctly???
It's always better to add a simple project with just web reference and then add the reference of this project on all the projects which requires it.
You can add a web service reference by doing the following steps:
right click on the project on the Solution Explorer
click Add Service Reference
click Advanced
you will find "Add Web Reference" at the end of the form
By #AMgdy 's solution,It'll auto generate a Reference.cs class.It defined all of method of webservices.
May be you called it wrong!!
Here is an example:
var serviceName = new ServiceName
{
Credentials = new NetworkCredential("Username", "Password", "Domain"),
Url = "Here you put the correct url of the web service if you published somewhere else"
};
serviceName.CallWebMethod();
make sure that you entered the correct Credential username and password and make sure the you published the webservice to a place you access it.
Have you defined any credential information in a config file in the web app? If so, the class library probably can't fetch them correctly. Just a guess though. And John Saunders is right. Seems a bit backwards reading your description of your apps structure.

Categories