I have the SoapUI where I am doing a web services test in which I add 3 data to the request and it gives me an answer, until here everything is fine.
It happens that I want to consume that webservice using C #, the code I have so far is:
private void button1_Click(object sender, EventArgs e)
{
string uno = "2018-12-05T17:00:00";
string dos = "3101009059";
string tres = "2018-11-28T00:00:00";
string xmlData = @"<con:contractNoticeReqBean>
<java:End_ymd>"+uno+ @"</java:End_ymd>
<java:Inst_reg_no>"+dos+@"</java:Inst_reg_no>
<java:Start_ymd>"+ tres + @"</java:Start_ymd>
</con:contractNoticeReqBean>";
XmlDocument xmlDoc = new XmlDocument();
xmlDoc.LoadXml(xmlData);
ServiceReference1.ContractInfoWServiceClient client = new ServiceReference1.ContractInfoWServiceClient();
var data = client.getRequestContractNotice(xmlDoc);
}
But when I run the code it throws me an error in the line xmlDoc.LoadXml(xmlData);
the error is:
System.Xml.XmlException: '' with 'is an undeclared prefix. line 1, position 2. '
If I try to send the string xmlData
the error that points me before I can run the code in line var data = client.getRequestContractNotice(xmlDoc);
is:
Argument 1: Unable to convert from 'System.Xml.XmlDocument' to 'xml.ServiceReference1.ContractNoticeReqBean'
How can I solve this in order to be able to send those 3 data correctly?
EDITED
Edit it in this way to send the data:
private void button1_Click(object sender, EventArgs e)
{
DateTime final = DateTime.Parse("2018-12-05T17:00:00");
string ints = "3101009059";
DateTime inicio = DateTime.Parse("2018-11-28T00:00:00");
ServiceReference1.ContractNoticeReqBean reqBean=new ServiceReference1.ContractNoticeReqBean();
reqBean.End_ymd = final;
reqBean.Inst_reg_no = ints;
reqBean.Start_ymd = inicio;
ServiceReference1.ContractInfoWServiceClient client = new ServiceReference1.ContractInfoWServiceClient();
var data = client.getRequestContractNotice(reqBean);
listBox1.Items.Add(data);
}
I want to receive this information:
But my way out is this:
What is my fault now?