locked
How to pass SQL raw queries while posting the data.? RRS feed

  • Question

  • User-1024101449 posted

    I am using some web service and for testing i am posting data through POSTMAN tool. Inside the body of the postman tool, i am passing credential of the database and SQL Queries. 
    Finally i am getting the response as string value.


    The same i want to post through my ASP.net C# code.


    i am trying to develop some code below. but, i am not sure where to mention the SQL raw queries and parameter.


    pls. clarify


    In the postman tool i'm passing the below XML in body section.


    <s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/">
    <s:Header>
    <ServiceContext token="temporary/127.0.0.1-1205239338115-25203285"
    xmlns="http://context.core.datamodel.fs.documentum.abc.com/">
    <Identities xsi:type="RepositoryIdentity"
    userName="pass"
    password="pass"
    repositoryName="Test"
    domain=""
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"/>
    <RuntimeProperties/>
    </ServiceContext>
    </s:Header>
    <s:Body xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xmlns:xsd="http://www.w3.org/2001/XMLSchema">
    <execute xmlns="http://core.services.fs.documentum.abc.com/">
    <query xsi:type="q1:PassthroughQuery"
    queryString="select Emp_id from employee where emp_number ='A-10101-SEC-A'" // Passing emp_number
    xmlns=""
    xmlns:q1="http://query.core.datamodel.fs.documentum.abc.com/">
    <q1:repositories>Test</q1:repositories>
    </query>
    <execution startingIndex="0"
    maxResultCount="100"
    maxResultPerSource="50"
    cacheStrategyType="DEFAULT_CACHE_STRATEGY"
    xmlns=""/>
    </execute>
    </s:Body>
    </s:Envelope>


    Instead of XML, i just want to post through asp.net code. i have written below.
    But, i am not sure where i want to pass the SQL Queries and Repository name.


    .NET Code
    -----------
    const string URL = "http://server1.mnet.tefee.intranet:80/services/core/QueryService";
                const string DATA = @"{""emp_number"": ""A-10101-SEC-A""}";
                System.Net.Http.HttpClient client = new System.Net.Http.HttpClient();
                client.BaseAddress = new System.Uri(URL);
                byte[] cred = UTF8Encoding.UTF8.GetBytes("pass:pass");
                client.DefaultRequestHeaders.Authorization = new System.Net.Http.Headers.AuthenticationHeaderValue("Basic", Convert.ToBase64String(cred));
                client.DefaultRequestHeaders.Accept.Add(new System.Net.Http.Headers.MediaTypeWithQualityHeaderValue("text/xml"));


                System.Net.Http.HttpContent content = new StringContent(DATA, UTF8Encoding.UTF8, "text/xml");
                HttpResponseMessage messge = client.PostAsync(URL, content).Result;
                string description = string.Empty;
                if (messge.IsSuccessStatusCode)
                {
                    string result = messge.Content.ReadAsStringAsync().Result;
                    description = result;
                }

    Tuesday, April 30, 2019 5:03 AM

Answers