httpclient soap request c#
C#
public async Task<int> AddNumbersAsync(Uri uri, int a, int b)
{
var soapString = this.ConstructSoapRequest(a, b);
using (var client = new HttpClient())
{
client.DefaultRequestHeaders.Add("SOAPAction", "http://CalculatorService/ICalculatorService/Add");
var content = new StringContent(soapString, Encoding.UTF8, "text/xml");
using (var response = await client.PostAsync(uri, content))
{
var soapResponse = await response.Content.ReadAsStringAsync();
return this.ParseSoapResponse(soapResponse);
}
}
}
private string ConstructSoapRequest(int a, int b)
{
return String.Format(@"<?xml version=""1.0"" encoding=""utf-8""?>
<s:Envelope xmlns:s=""http://schemas.xmlsoap.org/soap/envelope/"">
<s:Body>
<Add xmlns=""http://CalculatorService/"">
<a>{0}</a>
<b>{1}</b>
</Add>
</s:Body>
</s:Envelope>", a, b);
}
private int ParseSoapResponse(string response)
{
var soap = XDocument.Parse(response);
XNamespace ns = "http://CalculatorService/";
var result = soap.Descendants(ns + "AddResponse").First().Element(ns + "AddResult").Value;
return Int32.Parse(result);
}
Also in C#:
- Title
- c# two dimensional array
- Category
- C#
- Title
- length of a string c#
- Category
- C#
- Title
- c# round to closest multiple
- Category
- C#
- Title
- remove items from list c# condition
- Category
- C#
- Title
- C# get all child classes of a class
- Category
- C#
- Title
- x angle oes back after 90 unity
- Category
- C#
- Title
- how to convert object in string JSON c#
- Category
- C#
- Title
- transform.Translate movement
- Category
- C#
- Title
- c# write variable in string
- Category
- C#
- Title
- if a method doesnt rutern a value, what shouyld i reeturn c#
- Category
- C#
- Title
- c# discord bot
- Category
- C#
- Title
- bash if null or empty
- Category
- C#
- Title
- unity detect number key
- Category
- C#
- Title
- c# new dictionary linq
- Category
- C#
- Title
- how to close a form c#
- Category
- C#
- Title
- access dic by key c#
- Category
- C#
- Title
- how to move clipping planes C# in unity
- Category
- C#
- Title
- c# nameof
- Category
- C#
- Title
- open new window c# wpf
- Category
- C#
- Title
- get normal from 3 points
- Category
- C#
- Title
- how to retrive an enum string value instead of number in c# controller
- Category
- C#
- Title
- unity search for specific text in a string
- Category
- C#
- Title
- c# httpclient postasync stringcontent
- Category
- C#
- Title
- unity multiply xyz of two vectors
- Category
- C#
- Title
- iterate through xpdictionary devexpress
- Category
- C#
- Title
- c# string replace comma with newline
- Category
- C#
- Title
- insert new item listview c#
- Category
- C#
- Title
- how to turn 3 floats into quartenion
- Category
- C#
- Title
- unity draw wire square
- Category
- C#
- Title
- unity 3d mouse look script
- Category
- C#
- Title
- get list length c#
- Category
- C#
- Title
- get gameobject child by name
- Category
- C#
- Title
- findobject getcomponent
- Category
- C#
- Title
- xamarin forms alarm
- Category
- C#
- Title
- c# array inst working
- Category
- C#
- Title
- question mark operator in c#
- Category
- C#
- Title
- how to convert string to bool c#
- Category
- C#
- Title
- c# how to run external program with args
- Category
- C#
- Title
- if entity.is Transient() Update Mvc 5 c#
- Category
- C#
- Title
- bubble sort c#
- Category
- C#
- Title
- C# copy string except for last letter
- Category
- C#
- Title
- c# bitmap to picturebox
- Category
- C#
- Title
- the request was aborted could not create ssl/tls secure channel. c# restsharp
- Category
- C#
- Title
- c# loop through object
- Category
- C#
- Title
- math class C# exponents
- Category
- C#
- Title
- c# download string url
- Category
- C#
- Title
- message authorization has been denied for this request. fiddler
- Category
- C#
- Title
- unity3d raycast
- Category
- C#
- Title
- unity3d invector expand fsm controller
- Category
- C#
- Title
- c# convert int to string
- Category
- C#
- Title
- asp.net render control to string
- Category
- C#
- Title
- c# Sleep
- Category
- C#
- Title
- c# method info extension
- Category
- C#
- Title
- c# serialize
- Category
- C#
- Title
- C# Unknown column 'FundAllocation' in 'field list
- Category
- C#
- Title
- unity create gameobject
- Category
- C#
- Title
- c# web form compare dates
- Category
- C#
- Title
- c# find index element array
- Category
- C#
- Title
- random class
- Category
- C#
- Title
- c# stop loop in method
- Category
- C#
- Title
- c# select first value from list
- Category
- C#
- Title
- c# events and delegates
- Category
- C#
- Title
- percentage in c#
- Category
- C#
- Title
- use newtonsoft json to clone object
- Category
- C#
- Title
- how to reference a child object unity
- Category
- C#
- Title
- unity while in trigger
- Category
- C#
- Title
- c# reflection create generic type
- Category
- C#
- Title
- c# get enum value from string
- Category
- C#
- Title
- accessing form controls from another class c#
- Category
- C#
- Title
- c# date
- Category
- C#
- Title
- unity mouse click position
- Category
- C#
- Title
- c# byte array to bitmap
- Category
- C#
- Title
- unity ui change sprite
- Category
- C#
- Title
- c# else if
- Category
- C#
- Title
- transform object according to its parent unity
- Category
- C#
- Title
- query associative table ef6
- Category
- C#
- Title
- mongodb c# batch find
- Category
- C#
- Title
- c# null conditional operator if statement
- Category
- C#
- Title
- void start
- Category
- C#
- Title
- c# how to print
- Category
- C#
- Title
- c# wait for seconds
- Category
- C#
- Title
- verifyusertokenasync password reset token
- Category
- C#
- Title
- c# clear list items
- Category
- C#
- Title
- unity separator in inspector
- Category
- C#
- Title
- c# get char from string
- Category
- C#
- Title
- C# Into To Tring Debug.Log
- Category
- C#
- Title
- how do loops on C#
- Category
- C#
- Title
- c# windows forms draw pixel
- Category
- C#
- Title
- c# clone stream
- Category
- C#
- Title
- open link c#
- Category
- C#
- Title
- gaussian blur unity sprite 2D
- Category
- C#
- Title
- rotate to face direction
- Category
- C#
- Title
- draw sphere cast unity with program
- Category
- C#
- Title
- file picker uwp c#
- Category
- C#
- Title
- get string character by index c#
- Category
- C#
- Title
- c# or
- Category
- C#
- Title
- doest all the methos in interface need to implement c#
- Category
- C#
- Title
- c# anonymous class
- Category
- C#
- Title
- C# .net core convert to int round up
- Category
- C#
- Title
- unity delete all children
- Category
- C#