SOAP attachement issue
| From: | Photon Kev | Date: | Tue, 13 Mar 2007 20:06:10 +0000 |
| Subject: | SOAP attachement issue | ||
| Groups: | php.pear.general | ||
| Request: | Send a blank email to pear-general+get-26839@lists.php.net to get a copy of this message | ||
**I'm having problems attaching a CSV file in the SOAP client. In general,
there's no issue connecting to the SOAP server and executing methods. The
only problem is that of sending over files.
Here is the basic example script:
<?php
require_once('SOAP/Client.php');
define('ENDPOINT','URL');
define('LOGIN_USER','username');
define('LOGIN_PASS','password');
$client= new SOAP_Client(ENDPOINT);
$method = login;
$params = array('username'=>LOGIN_USER, 'password'=>LOGIN_PASS);
$client->call($method, $params);
$filename = 'test.csv';
$filestring = file_get_contents($filename);
$inputstring = new SOAP_Attachment('test','',$filename, $filestring);
$args = array("input"=>$inputstring );
$client->call('SOAP_FUNCTION',$args);
?>
Added echoes to SOAP::Client <soap::Client> that show the file is being
attached:
Array
(
[input] => SOAP_Attachment Object
(
[value] =>
[name] => test
[type] =>
[namespace] =>
[type_namespace] =>
[attributes] => Array
(
[href] => cid:4290caa6f9db1e3e44c3150c8a4d5dbc
)
[arrayType] =>
[options] => Array
(
[attachment] => Array
(
[body] => CUSTID,FIRSTNAME,LASTNAME,EMAILADDRESS,EMAILTYPE,GENDER,NEWSLETTER
1,fname1,lname1,email1@test.com,,M,Y
2,fname2,lname2,email2@test.com,,F,N
[disposition] => test.csv
[content_type] =>
[encoding] => base64
[cid] => 4290caa6f9db1e3e44c3150c8a4d5dbc
)
)
[nqn] => QName Object
(
[name] => test
[ns] =>
[namespace] =>
)
[tqn] => QName Object
(
[name] =>
[ns] =>
[namespace] =>
)
[type_prefix] =>
)
)
Here, I'm printing out the xml before being sent, which shows garbage before
the xml and attachment contents after the closing soap tag:
?????)??\http://schemas.xmlsoap.org/soap/envelope/???<?xml version="1.0"
encoding="UTF-8"?>
<SOAP-ENV:Envelope xmlns:SOAP-ENV=
"http://schemas.xmlsoap.org/soap/envelope/"<http://schemas.xmlsoap.org/soap/envelope/>
xmlns:xsd="http://www.w3.org/2001/XMLSchema"<http://www.w3.org/2001/XMLSchema>
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"<http://www.w3.org/2001/XMLSchema-instance>
xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/"<http://schemas..xmlsoap.org/soap/encoding/>
SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"<http://schemas.xmlsoap.org/soap/encoding/>>
<SOAP-ENV:Body>
<updateDataSource>
<csvFileName xsi:type="xsd:string">MasterList.csv</csvFileName>
<delimitedBy xsi:type="xsd:string">COMMA</delimitedBy>
<delimiterString xsi:type="xsd:string"></delimiterString>
<folderName xsi:type="xsd:string">central_data_frank</folderName>
<tableName xsi:type="xsd:string">MasterListFrank</tableName>
<enclosedBy xsi:type="xsd:string"></enclosedBy>
<charset xsi:type="xsd:string">iso-8859-1</charset>
<synchronous xsi:type="xsd:boolean">true</synchronous>
<CUSTID xsi:type="xsd:string">CUSTID</CUSTID>
<FIRSTNAME xsi:type="xsd:string">FIRSTNAME</FIRSTNAME>
<LASTNAME xsi:type="xsd:string">LASTNAME</LASTNAME>
<EMAILADDRESS xsi:type="xsd:string">EMAILADDRESS</EMAILADDRESS>
<EMAILTYPE xsi:type="xsd:string">EMAILTYPE</EMAILTYPE>
<GENDER xsi:type="xsd:string">GENDER</GENDER>
<NEWSLETTER xsi:type="xsd:string">NEWSLETTER</NEWSLETTER>
<test href="cid:4290caa6f9db1e3e44c3150c8a4d5dbc"<cid:4290caa6f9db1e3e44c3150c8a4d5dbc>xsi:nil="true"/></updateDataSource>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>
???
?????4290caa6f9db1e3e44c3150c8a4d5dbcCUSTID,FIRSTNAME,LASTNAME,EMAILADDRESS,EMAILTYPE,GENDER,NEWSLETTER
1,fname1,lname1,email1@test.com,,M,Y
2,fname2,lname2,email2@test.com,,F,N
??
@??????????