I'm trying to access a PHP webservice through an ASP.NET application
ccbusca.pesqwebservice client = new ccbusca.pesqwebservice();
client.Url = "http://www.ccbusca.com.br/webservice.php";
ret = client.ws_pesqcpf("VISUALFIX01", "XXXX@", "302X");
When I run this code snippet, I'm getting this error:
Additional information: The customer found the content type of 'text / html; charset = UTF-8, text / xml; charset = UTF-8 ', but I was expecting 'text / xml'.
The webservice response came right below in the same error message.
<?xml version="1.0" encoding="UTF-8"?><SOAP-ENV:Envelope SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/"><SOAP-ENV:Body><ns1:ws_pesqcpfResponse xmlns:ns1="urn:cbuscaws"><return xsi:type="xsd:string"><?xml version="1.0" encoding="utf-8"?>
<xml>
<ocorrencia>
<codocor>0</codocor>
<msgocor>encontrado</msgocor>
</ocorrencia>
<cadastro>
<cpf>XXX</cpf>
<nome>OTAVIO</nome>
...
I also tried to make the request using HttpWebRequest, but without success.
string url = "http://www.ccbusca.com.br/webservice.php/ws_pesqcpf?usr=VISUALFIX01&pwd=visualfix2016@&cpf=30264304802";
System.Net.WebRequest request;
System.Net.WebResponse response;
System.IO.Stream dataStream;
System.IO.StreamReader reader;
string responseFromServer;
try
{
// Create a request for the URL.
request = System.Net.WebRequest.Create(url);
// If required by the server, set the credentials.
request.Credentials = System.Net.CredentialCache.DefaultCredentials;
// Get the response.
response = request.GetResponse();
// Display the status.
Console.WriteLine(((System.Net.HttpWebResponse)response).StatusDescription);
if(((System.Net.HttpWebResponse)response).StatusCode == System.Net.HttpStatusCode.OK)
{
// Get the stream containing content returned by the server.
dataStream = response.GetResponseStream();
// Open the stream using a StreamReader for easy access.
reader = new System.IO.StreamReader(dataStream);
// Read the content.
responseFromServer = reader.ReadToEnd();
// Clean up the streams and the response.
reader.Close();
response.Close();
}
}
finally
{
request = null;
response = null;
dataStream = null;
reader = null;
}
In this way, I could not see the data. I returned an HTML code from a page that might be a default message for error 404.
Primary URL: link Method: ws_pesqcpf Parameters: usr, pwd, and cpf
So, should not my URL be this? link
Querying via SoapUI works. I can see the data.