简体   繁体   中英

Referencing code in VB.NET

I'm not at all familiar with VB.NET or ASP. I need to create a simple page which makes a call to a remote web service. I used the wsdl utility which comes with the DotNet SDK to generate a service proxy and write it to a VB file. Unfortunately I have no idea how to reference this code in either my ASPX file or the code behind VB file so I can create an instance of the proxy.

Edit: I should have qualified this by noting that I'm not using visual studio. I just coded up a .aspx with a .vb behind it and dropped it into an IIS location. Is there a way to do what you're suggesting outside of VS?

You need to add this code into your project so that it can be consumed.

Right click on your App_Code folder and select "Add Existing Item". This will bring up explorer. Use it to select the generated file and it will add it to your project.

Now you will be able to reference this code from within your page or code behind file

If there isn't an App_Code folder in your project, then right click on the project in solution explorer and select "Add New ASP.Net Folder"->App_Code

Or, instead of the wsdl utility:

In the solution explorer windows, r-click on the project, and select "add web reference". In the dialog that comes up, put in the url to the web service. In the web reference name box (lower right of that dialog), put in whatever you want to local alias for the service to be called.

So, if you put in a url of:

http://otherserver.com/otherservice.asmx

And, a web reference name of: xyz

To use it, your code would look like:

dim x as new xyz
var = x.methodname()

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM