I want to pass a base address with query input parameters for a WCF Service using web socket in ASP.NET with C#.
I created the base address Url dynamically.
By removing the query input parameters it is fine. But how could I pass these query parameters as base address based on which to generate the endpoint address
Getting the exception as below:
A base address cannot contain a Uri query string.
Parameter name: item
Below is the base address I need to send as request
<pre>https:
{
"requestData": "2834367eec9be180739b628ae73e89ceac49ad575a3d00876105fe0321b3fc4a" ,
"requestkData": "2834367eec9be180739b628ae73e89ceac49ad575a3d00876105fe0321b3fc4a"
}
& entityId=123}
Response expected:
wss:
{
"requestData": "2834367eec9be180739b628ae73e89ceac49ad575a3d00876105fe0321b3fc4a" ,
"requestkData": "2834367eec9be180739b628ae73e89ceac49ad575a3d00876105fe0321b3fc4a"
}
& entityId=123}
What I have tried:
Core code is as below:
string strHandShakeRequest = string.Empty;
try
{
Logger.Log("Fetching of Encryption With AES for handshake Starts", LogFilename.WebPageLog, 3, MethodInfo.GetCurrentMethod().Name);
string HandShakeParentUrl = hsk.HandShakeReqParentUrl;
string RequestKeyData = hsk.requestKData;
string RequestData = hsk.requestKData;
string EntityID = hsk.EntityId;
string json = @"
{
""requestData"": """ + RequestKeyData + @""" ,
""requestkData"": """ + RequestData + @"""
}
";
StringBuilder strRequest = new StringBuilder();
strRequest
.Append(HandShakeReqParentUrl)
.Append("=")
.Append("{ ")
.Append(json)
.Append("& ")
.Append("entityId=")
.Append("")
.Append(EntityId)
. Append("")
.Append("}");
strHandShakeRequest = strRequest.ToString();
Logger.Log("Fetching of Encryption With AES for handshake Ends", LogFilename.WebPageLog, 3, MethodInfo.GetCurrentMethod().Name);
}
catch (Exception ex)
{
throw ex;
}
return strHandShakeRequest;
Uri baseAddress = new Uri(strHandShakeRequest);
ServiceHost host = new ServiceHost(typeof(WebSocket_Stub.Service1), baseAddress);