标签: asmx

在winforms中,如何动态更改我的Web引用的URL?

我有2个网站提供相同的网络服务.对于Web服务SampleService,我想知道如何选择可供选择的Web服务器.

  • Web服务:"SampleService"
  • Web参考:"SampleWebReference"

网站服务网址:

问:如何根据用户选择以编程方式更改Web引用引用的站点?

web-reference asmx webservice-client winforms

0
推荐指数
1
解决办法
1723
查看次数

如何从ASMX Web服务调用获取干净/纯HTML

我试图使用jQuery .load()从asmx Web服务获取直接html:

$( '#靶')负载( 'MyService.asmx/GetHtml');

在.NET代码中,GetHtml()以字符串形式返回:

    [WebMethod(EnableSession = false)]
    [ScriptMethod(UseHttpGet = true, ResponseFormat = ResponseFormat.Xml)]
    public string GetHtml()
    {
        return "<span>Hi</span>";
    }
Run Code Online (Sandbox Code Playgroud)

返回:

<?xml version="1.0" encoding="utf-8"?>
<string xmlns="http://tempuri.org/">&lt;span&gt;Hi&lt;/span&gt;</string>
Run Code Online (Sandbox Code Playgroud)

请注意,字符串已编码.使用该编码,$ .load无法正常工作.显示的文本实际上显示了标签.

如何让WebMethod调用才能返回?

<span>Hi</span>
Run Code Online (Sandbox Code Playgroud)

asp.net jquery asmx

0
推荐指数
1
解决办法
6149
查看次数

当Operations接受接口时,从PHP调用ASMX Web服务

我有一个.Net Web服务,它有一个接受我作为参数编写的接口的方法.我们称这个接口为ICustomer.

你会如何从PHP调用这个方法?

方法定义是

    [WebMethod]
    public string RegisterCustomer(ICustomer customer)
    {
     ...
    }
Run Code Online (Sandbox Code Playgroud)

php c# web-services asmx

0
推荐指数
1
解决办法
2311
查看次数

ASP.NET C# - 实时通知方法

你认为这是一种检索通知的坏方法吗?这个WebMethod将通过JavaScript每10秒调用一次.有没有更好的方法呢?如果是这样请详细说明.谢谢.

[WebMethod]
[ScriptMethod(ResponseFormat = ResponseFormat.Json)]
public int[] GetNotifications()
{
    int[] Notifications = new int[3]{0, 0, 0};
    if (HttpContext.Current.User.Identity.IsAuthenticated) {
        string UserName = HttpContext.Current.User.Identity.Name;
        Notifications[0] = Notification.GetAll(UserName, false).Count;
        Notifications[1] = Message.GetAll(UserName, false).Count;
        Notifications[2] = Friendship.GetFriends(UserName, true).Count;
    }
    return Notifications;
}
Run Code Online (Sandbox Code Playgroud)

javascript c# asp.net asmx webmethod

0
推荐指数
1
解决办法
2203
查看次数

从ASMX服务返回ArrayList

我有几个关于Web服务的问题,如果有人能指出我正确的方向,我真的很感激.

在我的类库中,我有两个类:Hotel&RoomType.Hotel类包含RoomType对象的ArrayList.

在我的Web服务中,我有一个GetHotels方法如下:

[WebMethod]
[XmlInclude(typeof(Hotel))]
[XmlInclude(typeof(RoomType))]
public ArrayList GetHotels()
{
    return Sistema.GetInstance().GetHotels();
}
Run Code Online (Sandbox Code Playgroud)

类Sistema中的GetHotels(),从数据库中检索信息并返回一个ArrayList.

我不得不使用XMLInclude因为我得到了:

类型酒店(或RoomType)不是预期的.使用XmlInclude或SoapInclude属性指定静态未知的类型

然后在我的Web应用程序中,我有这个代码:

WebService sample = new Service();
ArrayList hotels = service.GetHotels();
Run Code Online (Sandbox Code Playgroud)

这不编译,所以我不得不改为以下代码:

WebService sample = new Service();
object[] hotels = service.GetHotels();
Run Code Online (Sandbox Code Playgroud)

这是我的第一个问题:是否可以返回一个ArrayList,或者每次我必须将结果转换为ArrayList?

知道ArrayList包含Hotel对象,我添加了以下代码:

foreach (Hotel hotel in hotels)
{
    ...        
}
Run Code Online (Sandbox Code Playgroud)

这个编译,但是当我执行时,我收到以下错误:

无法将类型为"System.Xml.XmlNode []"的对象强制转换为"Hotel".

所以,我的下一个问题是:如何将结果转换为Hotel对象并使用它?

c# asp.net web-services asmx

0
推荐指数
1
解决办法
9027
查看次数

Sitecore:来自asmx webservice的访问上下文

如该主题所述.我试图从独立的.asmx Web服务访问我的Sitecore上下文.想知道这是否是一种正确的做法.

web-services sitecore asmx

0
推荐指数
1
解决办法
1342
查看次数