1

首先,我是肥皂的初学者。

我正在尝试给服务打一个肥皂电话,并获得了一个来自 talend 的工作样本。我需要的是在 PHP 中进行类似的调用。

talend 的输出如下,(从 HTTP 请求中提取)

<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
  <soap:Body>
    <root>
      <request>
        <username>a@a.com</username>
        <password>md5sumlookalike</password>
        <webservice>GetCust</webservice>
        <refid>12343321</refid>
        <message>reserv#123</message>
      </request>
    </root>
  </soap:Body>
</soap:Envelope>

所以我写了一点 PHP,因为它可以用作脚本语言,也可以用于调用它的位置。试图了解如何拨打肥皂电话,我想出了这一点。

<?php
// Yes I know about the diffrent port issue here.  So I wgeted and stored it for use next to script
#   $soapClient = new SoapClient("http://123.123.123.123:8088/services", array("trace" => true)); 
    $soapClient = new SoapClient("wsdl", array("trace" => true)); 

    $error = 0; 
    try {   
        $info = $soapClient->__soapCall("invoke",
            array
            (
            new SoapParam("a@a.com", "username"),
            new SoapParam("md5sumish", "password"),
            new SoapParam("GetCust", "webservice"),
            new SoapParam("1234321", "refid"),
            new SoapParam("reserv#123", "message")

            )
        ); 
    } catch (SoapFault $fault) { 
        $error = 1; 
        echo 'ERROR: '.$fault->faultcode.'-'.$fault->faultstring; 
    } 

    if ($error == 0) { 
        print_r($output_headers);
        echo 'maybe it worked\n';
        unset($soapClient); 
    }   

?>

我最终通过wireshark在HTTP请求中看到以下内容。服务器只是不知道该怎么做,也没有响应。我不确定我需要从这里去哪里/去哪里。

<?xml version="1.0" encoding="UTF-8"?>
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns1="http://talend.org/esb/service/job">
  <SOAP-ENV:Body>
    <ns1:invokeInput>a@a.com</ns1:invokeInput>
    <password>md5sumish</password>
    <webservice>GetCust</webservice>
    <refid>1234321</refid>
    <message>reserv#123</message>
  </SOAP-ENV:Body>
</SOAP-ENV:Envelope>

所以我要问的是如何摆脱 ns1:invokeInput 并使其成为用户名。随着格式的其余部分对齐,请求看起来像 talend 的输出?

4

1 回答 1

0

这是我在 php 中执行的一个工作小脚本,用于调用导出为 soap 的 talend 教程服务:

//....
if (sizeof($_POST) > 0) {
    $name = $_POST['name'];
    $city = $_POST['city'];
    $client = new SoapClient("http://192.168.32.205:8080/DirectoryService/services/DirectoryService?wsdl", array( 'trace' => 1));

    $result = $client->runJob(array(
        '--context_param',
        'Name=' . $_POST['name'],
        '--context_param',
        'City=' . $_POST['city']
    ));
}
//...   

Talend 似乎对如何给出参数非常“基本”。使用此代码,它工作正常。

于 2013-02-20T11:56:56.163 回答