mardi 20 février 2018

convert json web Api response to soap response

I have an exist web API project, I have requirement to wrap the web api services in soap services. I create web service project. I called there to the web api, and got the response as json. now' my question is, how to convert the json response to wsdl/soap response code:

[WebMethod]
public  string Test2(GetMessagesRequest product)
{
   return CreateProductAsync(product);
    //return "";
}

static string CreateProductAsync(GetMessagesRequest product)
{

   System.Net.ServicePointManager.Expect100Continue = false;

    var client = new HttpClient();

    var res = client.PostAsJsonAsync(@"http://localhost:99/api/messaging/post/", product).Result; 

    object data = res.Content.ReadAsAsync<object>().Result;

    return new JavaScriptSerializer().Serialize(data);

    //HttpResponseMessage response =

   // response.EnsureSuccessStatusCode();



    // return URI of the created resource.

   // return response.Headers.Location;

}

Thanks




Aucun commentaire:

Enregistrer un commentaire