为什么我的网络服务拒绝显示调用按钮?

Hellow,

我有一个显示简单查询的Web服务。 Web服务一无所获。我的意思是,它返回的内容没有我找不到调用按钮的内容。我收到错误消息。

我的ASMX文件如下。

using System.Collections.Generic;
using System.Configuration;
using System.Data;
using System.Data.SqlClient;
using system.web.Script.Serialization;
using system.web.Services;

namespace El_Alamia.GetData
{
    [WebService(Namespace = "http://microsoft.com/webservices/")]
    //[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
    //[WebService(Namespace = "http://tempuri.org/")]
    [System.ComponentModel.ToolboxItem(false)]
    [system.web.Script.Services.scriptservice]
    public class GetJsonData : system.web.Services.WebService
    {
        [WebMethod]
        public void GetHomeData()
        {
            string cs = Configurationmanager.ConnectionStrings["AlaamiaConnectionString"].ConnectionString;
            List<HomePage> HomeList = new List<HomePage>();
            using (SqlConnection con = new SqlConnection(cs))
            {
                SqlCommand cmd = new SqlCommand("spGetData",con);
                cmd.CommandType = CommandType.StoredProcedure;
                con.Open();
                SqlDataReader rdr = cmd.ExecuteReader();
                while (rdr.Read())
                {
                    HomePage PageFormat = new HomePage();
                    PageFormat.TextPath = rdr["Text_Path"].ToString();
                    PageFormat.PicPath = rdr["Pic_Path"].ToString();
                    HomeList.Add(PageFormat);
                }
            }
            JavaScriptSerializer js = new JavaScriptSerializer();
            Context.Response.Write(js.Serialize(HomeList));
        }

        public class HomePage
        {
            public string TextPath { get; set; }
            public string PicPath { get; set; }
        }
    }
}

错误消息

This web service is using http://tempuri.org/ as its default namespace.
Recommendation: Change the default namespace before the XML Web service is made public.
Each XML Web service needs a unique namespace in order for client applications to distinguish it from other services on the Web. http://tempuri.org/ is available for XML Web services that are under development,but published XML Web services should use a more permanent namespace.

Your XML Web service should be identified by a namespace that you control. For example,you can use your company's Internet domain name as part of the namespace. Although many XML Web service namespaces look like URLs,they need not point to actual resources on the Web. (XML Web service namespaces are URIs.)

For XML Web services creating using ASP.NET,the default namespace can be changed using the WebService attribute's Namespace property. The WebService attribute is an attribute applied to the class that contains the XML Web service methods. Below is a code example that sets the namespace to "http://microsoft.com/webservices/":

C#

[WebService(Namespace="http://microsoft.com/webservices/")]
public class MyWebService {
    // implementation
}

,也要通知我,我的web.config拥有此功能

<webServices>
  <conformanceWarnings>
    <remove name='BasicProfile1_1'/>
  </conformanceWarnings>
  <protocols>
    <add name="HttpGet"/>
    <add name="HttpPost"/>
  </protocols>
</webServices>
gaoshao1982 回答:为什么我的网络服务拒绝显示调用按钮?

暂时没有好的解决方案,如果你有好的解决方案,请发邮件至:iooj@foxmail.com
本文链接:https://www.f2er.com/2446995.html

大家都在问