0

I'm new to C# and asp.net, but i will try to explain as good as i can.

I want to add a service reference from http://www8.something.com/service1.asmx to a service called localhost/WeatherParser.asmx in which I could use the methods from the service1.asmx.

I have tried adding service reference to my default.aspx like mentioned here and it worked ok, but how do i use a service in another service ?

Is it even possible and how ? Please give some - Explanations,examples and reference to another sources.

What it looks like in my head:

DefaultApp < Weatherservice.aspx < Servicereference(http://www8.something.com/service1.asmx)

If there are some other ways than I were able to think of please share.

Thanks in advance!

Community
  • 1
  • 1
Giedrius
  • 603
  • 1
  • 6
  • 26
  • If you are asking `is it possible to call web service from another web service?` , the answer is : Yes , according to [this](http://stackoverflow.com/questions/5751089/webservice-calling-another-webservice).And [this](http://www.c-sharpcorner.com/UploadFile/718fc8/calling-a-web-service-into-another-web-service-application/) should help you find out how to do so. – Null Jan 04 '17 at 19:33

1 Answers1

0

So first you create the Web service that you would like to use

[WebService(Namespace = "http://tempuri.org/")]
public class MyWebService{
    public string RunCodeThroughWebService()
    {
        //Do some stuff to the server or whatever you want to do
        return "Hello World";
    }
}

I am not sure how to call the web method in C# but here it is in JavaScript

function runWebService{
    $.ajax({
        url: '/webservices/MyWebService.asmx/RunCodeThroughWebService',
        data: { },
        type: 'POST',
        dataType: 'string',
        timeout: 50000,
        error: function(){  

        },
        success: function(result){              
            $('body').html(result); 
        }
    });         
}
Neil Busse
  • 139
  • 8