Dear all,
I try to make simple desktop application that calling some webservice. I make webservice using wso2 esb. But when I calling the service through my application it return error 500. Here is my class that calling the web service
private void button3_Click(object sender, EventArgs e)
{
try
{
ChangeUrl("https://192.168.24.129:9443/services/rate_DataService/");
ExampleWebMethod(txtFrom.Text, txtTo.Text, 12456);
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
}
public static void ChangeUrl(string webserviceEndpoint)
{
ExampleAPI = new WebService(webserviceEndpoint);
}
public static string ExampleWebMethod(string from, string to, decimal number)
{
ExampleAPI.PreInvoke();
ExampleAPI.AddParameter("param0", from);
ExampleAPI.AddParameter("param1", to);
ExampleAPI.AddParameter("param2", number.ToString());
try
{
ExampleAPI.Invoke("ExampleWebMethod");
}
finally { ExampleAPI.PosInvoke(); }
return ExampleAPI.ResultString;
}
and this is the Webservice class that I create
public void Invoke(string methodName)
{
Invoke(methodName, true);
}
private void Invoke(string methodName, bool encode)
{
AssertCanInvoke(methodName);
string soapStr =
@"<?xml version=""1.0"" encoding=""utf-8""?>
<soap:Envelope xmlns:xsi=""http://www.w3.org/2001/XMLSchema-instance""
xmlns:xsd=""http://www.w3.org/2001/XMLSchema""
xmlns:soap=""http://schemas.xmlsoap.org/soap/envelope/"">
<soap:Body>
<{0} xmlns=""http://tempuri.org/"">
{1}
</{0}>
</soap:Body>
</soap:Envelope>";
HttpWebRequest req = (HttpWebRequest)WebRequest.Create(Url);
req.ServerCertificateValidationCallback = ((sender, certificate, chain, sslPolicyErrors) => true);
req.Headers.Add("SOAPAction", "\"http://tempuri.org/" + methodName + "\"");
req.ContentType = "text/xml;charset=\"utf-8\"";
req.Accept = "text/xml";
req.Method = "POST";
using (Stream stm = req.GetRequestStream())
{
string postValues = "";
foreach (var param in Params)
{
if (encode) postValues += string.Format("<{0}>{1}</{0}>", HttpUtility.HtmlEncode(param.Key), HttpUtility.HtmlEncode(param.Value));
else postValues += string.Format("<{0}>{1}</{0}>", param.Key, param.Value);
}
soapStr = string.Format(soapStr, methodName, postValues);
using (StreamWriter stmw = new StreamWriter(stm))
{
stmw.Write(soapStr);
}
}
using (StreamReader responseReader = new StreamReader(req.GetResponse().GetResponseStream()))
{
string result = responseReader.ReadToEnd();
ResponseSOAP = XDocument.Parse(Utils.UnescapeString(result));
ExtractResult(methodName);
}
}
What I have tried:
I already try googling it and some said i need to setting the jsonSerialization size but since I using wso2 I cannot find where the web config located.
Is there anyone who know how to solved this problem
Thank you