代码
<?php
class WebServiceClient extends SoapClient
{
public $username;
public $password;
public $fileContent;
public $fileName;
public $fileType;
public function __doRequest($request, $location, $action, $version, $one_way = 0)
{
$request =
'<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" xmlns:tns="http://com.clarkston.cts.webservice.source.event/IEventUploadWSv1.wsdl" xmlns:types="http://com.clarkston.cts.webservice.source.event/IEventUploadWSv1.wsdl/encodedTypes" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:wsa="http://schemas.xmlsoap.org/ws/2004/03/addressing" xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd" xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd">
<soap:Header>
<wsse:Security>
<wsse:UsernameToken xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd" wsu:Id="SecurityToken-8c17c5b1-3c45-4eba-bae6-024642866e12">
<wsse:Username>'.$this->username.'</wsse:Username>
<wsse:Password Type="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-username-token-profile-1.0#PasswordText">'.$this->password.'</wsse:Password>
</wsse:UsernameToken>
</wsse:Security>
</soap:Header>
<soap:Body soap:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
<q1:fileUpload xmlns:q1="urn:com-clarkston-cts-webservice-source-event-IEventUploadWSv1">
<param0 href="#fur" />
</q1:fileUpload>
<q2:com_clarkston_cts_webservice_source_event_FileUploadRequest id="fur" xsi:type="q2:com_clarkston_cts_webservice_source_event_FileUploadRequest" xmlns:q2="http://com.clarkston.cts.webservice.source.event/IEventUploadWSv1.xsd">
<fileContent xsi:type="xsd:base64Binary">'.base64_encode($this->fileContent).'</fileContent>
<fileName xsi:type="xsd:string">'.$this->fileName.'</fileName>
<fileType xsi:type="xsd:string">'.$this->fileType.'</fileType>
</q2:com_clarkston_cts_webservice_source_event_FileUploadRequest>
</soap:Body>
</soap:Envelope>
';
$location = "http://www.clia.demo.livestockid.ca/CLTSDB/EventUploadWSv1?WSDL";
return parent::__doRequest($request, $location, $action, $version, $one_way);
}
}
$client = new WebServiceClient("http://www.clia.demo.livestockid.ca/CLTSDB/EventUploadWSv1?WSDL");
$client->username = "xxx";
$client->password = "xxx";
$client->fileContent = "okey-dokey";
$client->fileName = "alright.csv";
$client->fileType = "1";
echo $client->fileUpload();
?>
class WebServiceClient extends SoapClient
{
public $username;
public $password;
public $fileContent;
public $fileName;
public $fileType;
public function __doRequest($request, $location, $action, $version, $one_way = 0)
{
$request =
'<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" xmlns:tns="http://com.clarkston.cts.webservice.source.event/IEventUploadWSv1.wsdl" xmlns:types="http://com.clarkston.cts.webservice.source.event/IEventUploadWSv1.wsdl/encodedTypes" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:wsa="http://schemas.xmlsoap.org/ws/2004/03/addressing" xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd" xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd">
<soap:Header>
<wsse:Security>
<wsse:UsernameToken xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd" wsu:Id="SecurityToken-8c17c5b1-3c45-4eba-bae6-024642866e12">
<wsse:Username>'.$this->username.'</wsse:Username>
<wsse:Password Type="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-username-token-profile-1.0#PasswordText">'.$this->password.'</wsse:Password>
</wsse:UsernameToken>
</wsse:Security>
</soap:Header>
<soap:Body soap:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
<q1:fileUpload xmlns:q1="urn:com-clarkston-cts-webservice-source-event-IEventUploadWSv1">
<param0 href="#fur" />
</q1:fileUpload>
<q2:com_clarkston_cts_webservice_source_event_FileUploadRequest id="fur" xsi:type="q2:com_clarkston_cts_webservice_source_event_FileUploadRequest" xmlns:q2="http://com.clarkston.cts.webservice.source.event/IEventUploadWSv1.xsd">
<fileContent xsi:type="xsd:base64Binary">'.base64_encode($this->fileContent).'</fileContent>
<fileName xsi:type="xsd:string">'.$this->fileName.'</fileName>
<fileType xsi:type="xsd:string">'.$this->fileType.'</fileType>
</q2:com_clarkston_cts_webservice_source_event_FileUploadRequest>
</soap:Body>
</soap:Envelope>
';
$location = "http://www.clia.demo.livestockid.ca/CLTSDB/EventUploadWSv1?WSDL";
return parent::__doRequest($request, $location, $action, $version, $one_way);
}
}
$client = new WebServiceClient("http://www.clia.demo.livestockid.ca/CLTSDB/EventUploadWSv1?WSDL");
$client->username = "xxx";
$client->password = "xxx";
$client->fileContent = "okey-dokey";
$client->fileName = "alright.csv";
$client->fileType = "1";
echo $client->fileUpload();
?>