Click here to Skip to main content
14,244,354 members
Rate this:
Please Sign up or sign in to vote.
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.

What I have tried:

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;
            }
Posted
Updated 29-Apr-19 19:57pm
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)




CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100