0

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/" /> 
2
  • May you supply C# webservice response example? Commented Jun 21, 2013 at 2:23
  • I check that one but in those example I just saw they read webservice again in c#, not in PHP, is it same? I have no idea, can we create List with generic? Commented Jun 21, 2013 at 2:25

1 Answer 1

1

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.

Sign up to request clarification or add additional context in comments.

4 Comments

Thanks, but still I didnt get my answer, my question is if I just share my class with PHP developers is it enough for them to read object of my webservice? most of the example are just with int or string parameter, I am using class...
JavaScriptSerializer json_seri = new JavaScriptSerializer(); CustomerData cs_list = (CustomerData)json_seri.DeserializeObject("{ \" _V_CUST_CODE\":\"some data\" }"); reference to this codeproject.com/Tips/79435/Deserialize-JSON-with-C
I found it very hard, I dont want to restart the server and also I dont have VS in server to follow installation steps
I cannot find Package Manager Console in VS2008. some one help me please

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.