Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Returning JSON from Web Service
Message
De
22/05/2014 09:17:52
 
 
À
22/05/2014 07:33:18
Information générale
Forum:
ASP.NET
Catégorie:
Web Services
Versions des environnements
Environment:
C# 4.0
OS:
Windows Server 2012
Network:
Windows 2008 Server
Database:
MS SQL Server
Application:
Web
Divers
Thread ID:
01600242
Message ID:
01600454
Vues:
42
>To be honest, I don't know. I just followed a tutorial in MM.Net to create it based on an MM.Net Web Service Template. The first step is to create a New Web Site in Visual Studio, then select the template.

>Is there a way for me to tell what background technology is being used?

From what you've said previously you had a Web service (i.e SOAP and WSDL). If it has a .asmx extension that's what it is.

>
>>Is this a SOAP Web Service, WCF, or WebAPI?
>>
>>>Hi,
>>>
>>>I have a web service that returns my data as XML. How do I get it to return it as json instead?
>>>
>>>This works to return XML:
>>>
>>>    public CustomerEntity GetCustomerByCustomerNumber(string customerNumber)
>>>    {
>>>        // Instantiate the RunSheet business object
>>>        Customer oCustomer = new Customer();
>>>
>>>         return oCustomer.GetCustomerByCustomerNumber(customerNumber);
>>>}
>>>
>>>This is what I get from the above:
>>>
This XML file does not appear to have any style information associated with it. The document tree is shown below.
>>><CustomerEntity xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns="http://servername//xmlwebservices/">
>>><are_name>San Juan</are_name>
>>><cus_addr1>175 El Socorro Mn Rd</cus_addr1>
>>><cus_arefk>bf5d7cb4-1d72-4a5d-a279-de5b056a7205</cus_arefk>
>>><cus_bxtfk>10</cus_bxtfk>
>>><cus_cashonly>false</cus_cashonly>
>>><cus_cntfk>e3779ef3-79ab-4a85-91a9-d38117ce7f99</cus_cntfk>
>>><cus_company>Frank Cazabon</cus_company>
>>><cus_credit>false</cus_credit>
>>><cus_customs>false</cus_customs>
>>><cus_servicefee>true</cus_servicefee>
>>><cus_cutfk>1</cus_cutfk>
>>><cus_firstname>Frank</cus_firstname>
>>><cus_heathrow>false</cus_heathrow>
>>><cus_hold>false</cus_hold>
>>><cus_insurance>false</cus_insurance>
>>><cus_issue>1999-03-29T00:00:00</cus_issue>
>>><cus_lastname>Cazabon</cus_lastname>
>>><cus_maifk xsi:nil="true"/>
>>><cus_miami>true</cus_miami>
>>><cus_number>0001</cus_number>
>>><cus_PK>17d0638b-aebf-4d0b-b202-2a4abae0827c</cus_PK>
>>><cus_renewal>2014-03-29T00:00:00</cus_renewal>
>>><cus_rtefk>d1a8b4e4-2291-4d8a-95fc-2646b62088e1</cus_rtefk>
>>><cus_stafk>1</cus_stafk>
>>><cus_zipfk>6cdb7bdf-9d9b-4441-b884-54921d1cac46</cus_zipfk>
>>></CustomerEntity>
>>>
>>>I tried this, but it doesn't work:
>>>
    public string GetCustomerByCustomerNumber(string customerNumber)
>>>    {
>>>        // Instantiate the RunSheet business object
>>>        Customer oCustomer = new Customer();
>>>
>>>         string json = JsonConvert.SerializeObject(oCustomer.GetCustomerByCustomerNumber(customerNumber), Formatting.Indented);
>>>        return json;
>>>}
>>>
>>>This is what is returned:
>>>
>>>
This XML file does not appear to have any style information associated with it. The document tree is shown below.
>>><string xmlns="http://servername//xmlwebservices/">{ "$id": "1", "EntityKey": null }</string>
>>>
>>>Any ideas on what I need to do?
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform