Joined: 28 Dec 2010 |
Posts: 1 |
|
|
|
Posted: Tue Dec 28, 2010 8:56 am |
|
|
|
|
|
Good morning everyone.
I created a WebService function, which brings a file recorded in the database MSSQL, if I make the call by the URL of the Web Service, the procedure works normally, but when I try to bring NuSoap route, it returns the error "Response not of type text / xml: text / html ".
The routine should give a prompt for me to open or save the file, similar to the operation called in the URL of the Web Service.
Below is my function in C # and the call in PHP.
[WebMethod]
public string RetornaArquivo(string setupannotationid)
{
Guid annotationId = new Guid(setupannotationid);
CrmAuthenticationToken token = new CrmAuthenticationToken();
token.OrganizationName = "Organization";
token.AuthenticationType = 0;
CrmService _service = new CrmService();
_service.Url = "http://mysite.com/MSCrmServices/2007/CrmService.asmx";
_service.CrmAuthenticationTokenValue = token;
_service.Credentials = new System.Net.NetworkCredential("user", "password", "domain");
ColumnSet cols = new ColumnSet();
cols.Attributes = new string[] { "filename", "documentbody", "mimetype" };
annotation annotationAttachment = (annotation)_service.Retrieve(EntityName.annotation.ToString(), annotationId, cols);
byte[] fileContent = Convert.FromBase64String(annotationAttachment.documentbody);
Context.Response.ClearHeaders();
Context.Response.Clear();
Context.Response.AddHeader("content-disposition", "attachment; filename=" + annotationAttachment.filename);
Context.Response.BinaryWrite(fileContent);
Context.Response.End();
}
<?php
require_once('lib/nusoap.php');
$client = new nusoap_client('http://mysite.com/WService/WService.asmx?wsdl', true);
$err = $client->getError();
if ($err) {
echo "Erro na Construção do objeto";
echo $err;
}
$ap_param = array("setupannotationid" => "xxxxxxxxxxxxxxxxx");
$result = $client->call('RetornaArquivo', $ap_param);
?>
|
|