繁体   English   中英

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

[英]How to use service reference in a service asmx?

我是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)

如果有我无法想到的其他方法,请分享。

提前致谢!

因此,首先您要创建要使用的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); 
        }
    });         
}

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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