dongwei4096 2013-06-21 02:22
浏览 68
已采纳

PHP能够读取由Asp.net C#生成的Web服务的对象列表

I wrote a webservice in asp.net C# that return a list of a class, Now I want to check that a program that wrote in PHP can read my object or not,

If your answer is yes, would you tell me how and if the answer is no what should I add to my code? I asked this question because when I test my webservice I cannot see any xml, I am worry my webservice not working properly.

Please advice me in case if I want to show my result in xml format what should I do?

[WebMethod]
    public List<CustomerData> getFMSCustomerName()
    {
        string[] cols = {"V_CUST_CODE", "V_CUST_NAME"};

        ArrayList CustomerList = (ArrayList)db.Select(cols, "table1", "", "order by V_CUST_NAME");

        List<CustomerData> cd = new List<CustomerData>();
        foreach(DataRow dr in CustomerList)
            cd.Add(new CustomerData(dr["V_CUST_CODE"].ToString(), dr["V_CUST_NAME"].ToString()));

        return cd;
    }

My customer class:

public class CustomerData
{
    private string _V_CUST_CODE;
    private string _V_CUST_NAME;

    public String V_CUST_CODE
    {
        get
        {
            return this._V_CUST_CODE;
        }
        set
        {
            this._V_CUST_CODE = value;
        }
    }
    public String V_CUST_NAME
    {
        get
        {
            return this._V_CUST_NAME;
        }
        set
        {
            this._V_CUST_NAME = value;
        }
    }


    public CustomerData(String V_CUST_CODE, String V_CUST_NAME)
    {
        this.V_CUST_CODE = V_CUST_CODE;
        this.V_CUST_NAME = V_CUST_NAME;

    }

    public CustomerData() { }
}

My out put is:

 <?xml version="1.0" encoding="utf-8" ?> 
  <ArrayOfCustomerData xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns="http://123.23.45.34/sms/" /> 
  • 写回答

1条回答 默认 最新

  • douyan7916 2013-06-21 02:31
    关注

    Basically, you can. Please read this blog for more detail.

    This blog also good. Hope this help.

    You can convert object to xml by using this Using System.Xml.Serialization.XmlSerializer I think, this link directly can not help to this answer. I hope, this will help.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 luckysheet
  • ¥15 ZABBIX6.0L连接数据库报错,如何解决?(操作系统-centos)
  • ¥15 找一位技术过硬的游戏pj程序员
  • ¥15 matlab生成电测深三层曲线模型代码
  • ¥50 随机森林与房贷信用风险模型
  • ¥50 buildozer打包kivy app失败
  • ¥30 在vs2022里运行python代码
  • ¥15 不同尺寸货物如何寻找合适的包装箱型谱
  • ¥15 求解 yolo算法问题
  • ¥15 虚拟机打包apk出现错误