开发者

How to call a webservice in the same website?

开发者 https://www.devze.com 2022-12-16 14:27 出处:网络
I have to call a webservice published in the same website the caller aspx is. When I try to \"Add a Web Reference\" th开发者_开发知识库e editor does not show the webservice methods from the generated

I have to call a webservice published in the same website the caller aspx is.

When I try to "Add a Web Reference" th开发者_开发知识库e editor does not show the webservice methods from the generated namespace.

Do I have to use the "Add Web Reference" or is there another way because the webservice is in the same website?

Visual Studio 2005, C#

Thanks,

Eduardo


I used the way that Andy Rose wrote in comments:

Instantiate the webservice class and call the methods directly because it is accessible inside the project (no need to add web reference).


There are ways to trick it... You can deploy the app with the web service, then add reference to the deployed location.

Another idea is to just start it using ctrl-f5 so as to not start the debugger as well, then add a reference to your localhost:/.asmx

This will get all of the configuration information created in your web.config which, of course, you can modify later as necessary.


The Webreference itself is just a proxy implementation so that VS can pretend it knows how your webservice will react to calls to it (so you can compile), you can actually code without them (though it is much harder :)).

You have a few of options, that I can think of, if you want to do this:

  1. Create your webservice as a separate project, but deploy it to the same location. You will get mixed binaries in the bin directory, but otherwise it should work fine. In this way you can deploy each separately as needed.
  2. Consider pulling them apart into two separate applications. This might not be available for whatever reason.
  3. Create a stub webservice in your main project, which only has the function definitions (return type and parameters) and deploy that, then generate your webservice against that. You can then begin your development against the prototype and fill it in as necessary
  4. Do the two-step shuffle as Chris suggested. First create a approximate representation of your webservice, deploy it. Second create your proxy against it, create your web app, deploy it and test. Repeat as necessary.

Once your proxy is created you can change the URL it points to in the proxy bindings.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号