Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/asp.net/33.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 如何在服务asmx中使用服务引用?_C#_Asp.net_Web Services_Wcf_Soap - Fatal编程技术网

C# 如何在服务asmx中使用服务引用?

C# 如何在服务asmx中使用服务引用?,c#,asp.net,web-services,wcf,soap,C#,Asp.net,Web Services,Wcf,Soap,我对C#和asp.net还不熟悉,但我会尽力解释清楚 我想从http://www8.something.com/service1.asmx到名为localhost/WeatherParser.asmx的服务,在该服务中,我可以使用service1.asmx中的方法 我已经尝试将服务引用添加到我的default.aspx中,就像前面提到的那样,它工作正常,但是我如何在另一个服务中使用服务呢 有可能吗?怎么可能?请给出一些解释,例子和参考其他来源 它在我脑海中的样子: DefaultApp <

我对C#和asp.net还不熟悉,但我会尽力解释清楚

我想从
http://www8.something.com/service1.asmx
到名为
localhost/WeatherParser.asmx的服务,在该服务中,我可以使用service1.asmx中的方法

我已经尝试将服务引用添加到我的
default.aspx
中,就像前面提到的那样,它工作正常,但是我如何在另一个服务中使用服务呢

有可能吗?怎么可能?请给出一些解释,例子和参考其他来源

它在我脑海中的样子:

DefaultApp < Weatherservice.aspx < Servicereference(http://www8.something.com/service1.asmx)
DefaultApp
如果还有其他一些我想不到的方法,请分享


提前谢谢

因此,首先创建要使用的Web服务

[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";
    }
}
我不知道如何在C#中调用web方法,但这里是JavaScript

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

        },
        success: function(result){              
            $('body').html(result); 
        }
    });         
}

如果您询问
是否可以从另一个web服务调用web服务?
,答案是:可以,根据。并且应该可以帮助您了解如何这样做。