0
Good afternoon, I am building a Webservice in C#, I created a method that reads an XML sent as a request and should return the student’s name... The problem I’m actually facing is when I try to perform the test using Soapui, when sending XML I have an empty answer with error HTTP/1.1 400 Bad Request.
I would like help to solve this problem, because I don’t know how else to solve it...
Follow the code of my used classes:
Method of my webservice:
[WebMethod]
public String CapturarDados(String Xml) {
String retorno = "teste";
try
{
LeitorXml p = new LeitorXml();
retorno = p.LerXml(Xml);
}
catch (Exception ex )
{
retorno = ex.Message;
}
return retorno;
}
Leitorxml class:
public class LeitorXml
{
public String LerXml(String xml)
{
XmlDocument xDoc = new XmlDocument();
xDoc.LoadXml(xml);
XmlNodeList xnList = xDoc.GetElementsByTagName("Alunos");
string sNome = xnList[0]["nome"].InnerXml;
String retorno = sNome;
System.IO.StreamWriter file = new System.IO.StreamWriter("c:\\test.txt");
file.WriteLine(sNome);
file.Close();
return retorno;
}
}
XML input :
<Alunos>
<nome>Caio</nome>
<idade>21</idade>
<email>[email protected]</email>
<Endereco>
<Rua>Av.Lins de Vasconcelos</Rua>
<Bairro>Cambuci</Bairro>
<Cidade>São Paulo</Cidade>
<Estado>SP</Estado>
<Cep>16520-005</Cep>
</Endereco>
</Alunos>
Using visual studio the answer is OK.
But when using Soapui this is the problem presented:
Theoretically, the 400 BAD REQUEST error says that something in your HTTP request is incorrect, IE, maybe the format of the envelope you are sending is wrong, give a good check.
– Caique C.
It can even be a Soapui configuration.
– Caique C.
The strange thing is that if I use the Helloworld method that already comes works in Soapui, only this method that I created does not return anything and returns this error.
– Caio Novaes
But then it’s a completely different requisition, there’s no way to compare.
– Caique C.
Have you tried using . NET Webservice Studio? It is much lighter and simpler than Soapui, test there with it and tell me what happens. link
– DeRamon