0

我有我的index.php文件,它正在用糖调用 Web 服务,当我在本地 Apache 上运行它时它返回我作为响应,这个结果是可以的:

<soapenv:Envelope   <soapenv:Body> <ns:CommandResponseData> 
 <ns:Operation  name="BalanceAdjustment"> </ns:Operation>  
</ns:CommandResponseData> </soapenv:Body> </soapenv:Envelope>

我在详细视图中创建了一个额外的按钮,我计划将其称为此 Web 服务,但我不知道如何绑定该按钮、我的 index.php 文件以及该 Web 服务的结果以打包到某个字段中。出于测试目的,我想将整个响应放在 Contact 模块的字段 Comment 中的示例中:以便字段 Comment 应包含在整个响应之上(稍后我将对其进行解析)。

我创建了新按钮(目前不执行任何操作)

我在 view.detail.php 中创建了按钮。

<?php
if(!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point'); 
require_once('include/json_config.php'); 
require_once('include/MVC/View/views/view.detail.php'); 
class ContactsViewDetail extends ViewDetail
{
    function ContactsViewDetail()
    {
        parent::ViewDetail();
    }
    function display()
    {
        $this->dv->defs['templateMeta']['form']['buttons'][101] = array (
            'customCode' => '<input title="Call" accesskey="{$APP.LBL_PRINT_PDF_BUTTON_KEY}" class="button" onClick="javascript:CustomFunctionHere();" name="tckpdf" value="Call" type="button">');
        parent::display();
    }
}
?>

我会很感激这方面的帮助。所以概括一下:通过这个我的按钮,我想调用我的 index.php 文件,该文件将调用 Web 服务,我想在我的字段 Comment 中设置 Web 服务响应(我在 index.php 文件中得到响应为htmlspecialchars($client->__getLastResponse()

这是我目前用来调用某些 Web 服务的整个 index.php 文件。

    <?php
        include_once 'CommandRequestData.php';
        include_once 'CommandResponseData.php';

        $client = new SoapClient("http://127.0.0.1:8181/TisService?WSDL", array(
              "trace"      => 1,        // enable trace to view what is happening
              "exceptions" => 1,        // disable exceptions
              "cache_wsdl" => 0)        // disable any caching on the wsdl, encase you alter the wsdl server
          );

        $req = new CommandRequestData();

        $req->Environment->Parameter[0]->name = "ApplicationDomain";
        $req->Environment->Parameter[0]->value = "CAO_LDM_00";
        $req->Environment->Parameter[1]->name = "DefaultOperationNamespace";
        $req->Environment->Parameter[1]->value = "CA";

        $req->Command->Operation->namespace = "CA";
        $req->Command->Operation->name = "BalanceAdjustment";
        $req->Command->Operation->ParameterList->StringParameter[0]->name = "CustomerId";
        $req->Command->Operation->ParameterList->StringParameter[0]->_ = "387671100009";
        $req->Command->Operation->ParameterList->IntParameter[0]->name = "AmountOfUnits";
        $req->Command->Operation->ParameterList->IntParameter[0]->_ = "1000";
        $req->Command->Operation->ParameterList->IntParameter[1]->name = "ChargeCode";
        $req->Command->Operation->ParameterList->IntParameter[1]->_ = "120400119";

        try {
            $result = $client->ExecuteCommand($req);
$result->CommandResult->OperationResult->Operation->name . "<br /><br />";          
        }
        catch(SoapFault $e){
            echo "<br /><br />SoapFault: " . $e . "<br /><br />";
        }
        catch(Exception $e){

        }

        echo "<p>Response:".htmlspecialchars($client->__getLastResponse())."</p>";
    ?>
4

0 回答 0