0

我尝试连接到网络服务。我成功地使用了“AppendChunk”功能,但是没有标题,请有人告诉我我在做什么?我必须发送的 xml 看起来像这样:

<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
  <soap:Header>
    <WSCredential xmlns="http://cellact.com/">
      <Username>string</Username>
      <Password>string</Password>
      <Company>string</Company>
    </WSCredential>
  </soap:Header>
  <soap:Body>
    <AppendChunk xmlns="http://cellact.com/">
      <FileName>string</FileName>
      <buffer>base64Binary</buffer>
      <Offset>long</Offset>
    </AppendChunk>
  </soap:Body>
</soap:Envelope>

这是代码: require_once('/root/nusoap-0.9.5/lib/nusoap.php'); 函数 GetFileContents( $filename ) { $handle = fopen($filename, "r"); $contents = fread($handle, 文件大小($filename)); fclose($句柄); 返回$内容;} $parameters = array("stream" => GetFileContents("bookSmall.csv"));

    $client = new nusoap_client('http://cellactprolocal.net/mews/WSExt2.asmx?wsdl',true);
    $params = array(
        'FileName' => "book2.csv",
        'buffer' => $parameters,
        'Offset' => 0
    );                      
    $ns = "http://cellact.com";     

    $headers = "<WSCredential ><ns1:Username xmlns:ns1=\"$ns\">xxx</ns1:Username>
                <ns2:Password xmlns:ns2=\"$ns\">xxx/</ns2:Password>
                <ns3:Company xmlns:ns3=\"$ns\">xxx</ns3:Company>
                </WSCredential >";

    $client->setHeaders($headers);
    $result = $client->call('AppendChunk', $params, $ns);
    print_r($result);
4

1 回答 1

0

您应该在发送之前对文件进行编码,首先添加功能

function GetFileContents( $filename ) {
    $handle = fopen($filename, "r");
    $contents = fread($handle, filesize($filename));
    fclose($handle); 
    return $contents;
} 

然后更改代码:

$decodeContent   = base64_encode(GetFileContents("your file name")); 
$params = array(
    'FileName' => "test.csv",
    'buffer' => $decodeContent,
    'Offset' => 0
);
于 2013-11-10T14:54:58.980 回答