NuSphere Forums Forum Index
NuSphere Forums
Reply to topic
File Return (Open or Save)


Joined: 28 Dec 2010
Posts: 1
Reply with quote
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);
?>
View user's profileFind all posts by pfonsecaSend private messageMSN Messenger
File Return (Open or Save)
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
All times are GMT - 5 Hours  
Page 1 of 1  

  
  
 Reply to topic