如何在php中创建高级soaprequest

如何在php中创建高级soaprequest,php,soap,soap-client,Php,Soap,Soap Client,嗨,我没有很多编程web服务客户端的经验。在过去(在常见的web服务之前),我使用php,所以我要回到我的根 使用soapui,我创建了以下(工作)请求: ?> 我真的希望有人能帮我。 提前谢谢 致以亲切的问候, Mijno经过一天的辛勤工作,搜索互联网和大量的尝试和错误,我设法让它工作起来 下面是实现此技巧的代码: <?php // maken the functions that we are going to use function objectToArray($d) {

嗨,我没有很多编程web服务客户端的经验。在过去(在常见的web服务之前),我使用php,所以我要回到我的根

使用soapui,我创建了以下(工作)请求:

?>

我真的希望有人能帮我。 提前谢谢

致以亲切的问候,
Mijno

经过一天的辛勤工作,搜索互联网和大量的尝试和错误,我设法让它工作起来

下面是实现此技巧的代码:

    <?php

// maken the functions that we are going to use
function objectToArray($d) {
        if (is_object($d)) {
            // Gets the properties of the given object
            // with get_object_vars function
            $d = get_object_vars($d);
            echo "\n\n";
        }

        if (is_array($d)) {
            /*
            * Return array converted to object
            * Using __FUNCTION__ (Magic constant)
            * for recursive call
            */
            return array_map(__FUNCTION__, $d);
        }
        else {
            // Return array
            echo "\n\n";
            return $d;
        }
    }




// Fill in the parameters, this will be replaced with results from a form & an initialisation file
$soap_EndPoint          = "http://somehost:8080/EngineService/EngineService";
$soap_Wsdl              = "${soap_EndPoint}?wsdl";
$p_strDriver            = "base64encodedstring";
$p_strFileName          = "INPUT";
$p_strFileReturnRegEx   = "^.*.(pdf|dlf)$";
$p_strIncludeHeader = "True";
$p_strIncludeMessage    = "True";
$p_strPubFile           = "InteractiveDocument.pub";
$p_strEngineKey     = "removedstring";


// preparing soap client connection 

$soap_opts = array (
        'location'   =>  $soap_EndPoint ,
        'style'      =>  SOAP_DOCUMENT,
        'use'        =>  SOAP_LITERAL,
        'cache_wsdl' =>  WSDL_CACHE_NONE,
        'exceptions' =>  TRUE,
        'trace'      =>  TRUE,
        'compression' => SOAP_COMPRESSION_ACCEPT | SOAP_COMPRESSION_GZIP);


$soapclient_result = new SoapClient($soap_Wsdl, $soap_opts);
$soap_header = new SoapHeader("urn:hpexstream-services/Engine",'','',FALSE);
$soap_param = array("Compose"=> array("EWSComposeRequest" => array( "driver" => array( "driver" => $p_strDriver, "fileName" => $p_strFileName), "engineOptions" => array( "name" => "KEY", "value" => $p_strEngineKey), "fileReturnRegEx" => $p_strFileReturnRegEx, "includeHeader" => $p_strIncludeHeader, "includeMessageFile" => $p_strIncludeMessage, "pubFile" => $p_strPubFile)));



try {
    $result = $soapclient_result->__soapCall("Compose", $soap_param, NULL, $soap_header, $soap_outputHeaders);

    /* turn on for debuggin
    echo $soapclient_result->__getLastRequest();
    echo "\n\n";
    echo $soapclient_result->__getLastResponse(); 
    echo "\n\n";
    echo $soapclient_result->__getLastResponseHeaders(); 
    echo $soapclient_result->__getTypes(); 
    echo "\n\n";
        */

// the result is set in objects instead of an array     
$array = objectToArray($result);


//  creating some variables for the files i receive from the soap server
$timeStamp  = Time();
$msgFile        .= 'hpoutput/'. $timeStamp . '_messageFile.txt';
$dlfFile        .= 'hpoutput/'. $timeStamp . '_'. $array["return"]["files"]["fileName"];

// saving the messagefile to the server
$var_str    = var_export($array["return"]["engineMessage"], true);
file_put_contents($msgFile, $var_str);

// saving the actual output file to the server 
$var_str    = serialize($array["return"]["files"]["fileOutput"]);
file_put_contents($dlfFile, $var_str);


} catch (SoapFault $fault) {

    trigger_error("SOAP Fault: (faultcode: {$fault->faultcode}, faultstring: {$fault->faultstring})", E_USER_ERROR);

}


?>

如何在java中创建高级soap请求

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:eng="urn:hpexstream-services/Engine">
<soapenv:Header/>
<soapenv:Body>
<eng:Compose>
<EWSComposeRequest>
<driver>
<driver>PGN1c3RvbWVyPg0KICAgPGZpcnN0TmFtZT5NZXJpZW08L2ZpcnN0TmFtZT4NCiAgICAgIDxsYXN0TmFtZT5CZWxtb2todGFyPC9sYXN0TmFtZT4NCiAgIA0KPC9jdXN0b21lcj4NCjxjdXN0b21lcj4NCiAgIDxmaXJzdE5hbWU+QWhtZWQ8L2ZpcnN0TmFtZT4NCiAgICAgIDxsYXN0TmFtZT5CZW91bWFpejwvbGFzdE5hbWU+DQogICANCjwvY3VzdG9tZXI+DQo8Y3VzdG9tZXI+DQogICA8Zmlyc3ROYW1lPkhhbXphPC9maXJzdE5hbWU+DQogICAgICA8bGFzdE5hbWU+QmVua2hhbGVkPC9sYXN0TmFtZT4NCiAgIA0KPC9jdXN0b21lcj4=</driver>
<fileName>INPUT</fileName>
</driver>
<driverEncoding>UTF-8</driverEncoding>
<engineOptions>
<name>RUNMODE</name>
<value>PRODUCTION</value>
</engineOptions>
<fileReturnRegEx>?</fileReturnRegEx>
<includeHeader>?</includeHeader>
<includeMessageFile>?</includeMessageFile>
<outputFile>
<directory>out</directory>
<fileName>sortie</fileName>
</outputFile>
<pubFile>PackageTest.pub</pubFile>
</EWSComposeRequest>
</eng:Compose>
</soapenv:Body>
</soapenv:Envelope>

2.中国的一个中国的一个中国的一个中国的一个中国的一个中国的一个中国的一个中国的一个中国的一个中国的一个中国的一个中国的一个中国的一个中国的一个中国的一个中国的一个中国的一个中国的一个中国的一个中国的一个中国的一个中国的一个中国的一个中国的一个中国的一个中国的一个中国的一个中国的TTTTZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBCAGICA8BGFZDE5HBWU+QmVua2hhbGVkPC9sYXN0TmFtZT4NCiAgIA0KPC9jdXN0b21lcj4=
输入
UTF-8
运行模式
生产
?
?
?
出来
出动
PackageTest.pub
    <?php

// maken the functions that we are going to use
function objectToArray($d) {
        if (is_object($d)) {
            // Gets the properties of the given object
            // with get_object_vars function
            $d = get_object_vars($d);
            echo "\n\n";
        }

        if (is_array($d)) {
            /*
            * Return array converted to object
            * Using __FUNCTION__ (Magic constant)
            * for recursive call
            */
            return array_map(__FUNCTION__, $d);
        }
        else {
            // Return array
            echo "\n\n";
            return $d;
        }
    }




// Fill in the parameters, this will be replaced with results from a form & an initialisation file
$soap_EndPoint          = "http://somehost:8080/EngineService/EngineService";
$soap_Wsdl              = "${soap_EndPoint}?wsdl";
$p_strDriver            = "base64encodedstring";
$p_strFileName          = "INPUT";
$p_strFileReturnRegEx   = "^.*.(pdf|dlf)$";
$p_strIncludeHeader = "True";
$p_strIncludeMessage    = "True";
$p_strPubFile           = "InteractiveDocument.pub";
$p_strEngineKey     = "removedstring";


// preparing soap client connection 

$soap_opts = array (
        'location'   =>  $soap_EndPoint ,
        'style'      =>  SOAP_DOCUMENT,
        'use'        =>  SOAP_LITERAL,
        'cache_wsdl' =>  WSDL_CACHE_NONE,
        'exceptions' =>  TRUE,
        'trace'      =>  TRUE,
        'compression' => SOAP_COMPRESSION_ACCEPT | SOAP_COMPRESSION_GZIP);


$soapclient_result = new SoapClient($soap_Wsdl, $soap_opts);
$soap_header = new SoapHeader("urn:hpexstream-services/Engine",'','',FALSE);
$soap_param = array("Compose"=> array("EWSComposeRequest" => array( "driver" => array( "driver" => $p_strDriver, "fileName" => $p_strFileName), "engineOptions" => array( "name" => "KEY", "value" => $p_strEngineKey), "fileReturnRegEx" => $p_strFileReturnRegEx, "includeHeader" => $p_strIncludeHeader, "includeMessageFile" => $p_strIncludeMessage, "pubFile" => $p_strPubFile)));



try {
    $result = $soapclient_result->__soapCall("Compose", $soap_param, NULL, $soap_header, $soap_outputHeaders);

    /* turn on for debuggin
    echo $soapclient_result->__getLastRequest();
    echo "\n\n";
    echo $soapclient_result->__getLastResponse(); 
    echo "\n\n";
    echo $soapclient_result->__getLastResponseHeaders(); 
    echo $soapclient_result->__getTypes(); 
    echo "\n\n";
        */

// the result is set in objects instead of an array     
$array = objectToArray($result);


//  creating some variables for the files i receive from the soap server
$timeStamp  = Time();
$msgFile        .= 'hpoutput/'. $timeStamp . '_messageFile.txt';
$dlfFile        .= 'hpoutput/'. $timeStamp . '_'. $array["return"]["files"]["fileName"];

// saving the messagefile to the server
$var_str    = var_export($array["return"]["engineMessage"], true);
file_put_contents($msgFile, $var_str);

// saving the actual output file to the server 
$var_str    = serialize($array["return"]["files"]["fileOutput"]);
file_put_contents($dlfFile, $var_str);


} catch (SoapFault $fault) {

    trigger_error("SOAP Fault: (faultcode: {$fault->faultcode}, faultstring: {$fault->faultstring})", E_USER_ERROR);

}


?>
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:eng="urn:hpexstream-services/Engine">
<soapenv:Header/>
<soapenv:Body>
<eng:Compose>
<EWSComposeRequest>
<driver>
<driver>PGN1c3RvbWVyPg0KICAgPGZpcnN0TmFtZT5NZXJpZW08L2ZpcnN0TmFtZT4NCiAgICAgIDxsYXN0TmFtZT5CZWxtb2todGFyPC9sYXN0TmFtZT4NCiAgIA0KPC9jdXN0b21lcj4NCjxjdXN0b21lcj4NCiAgIDxmaXJzdE5hbWU+QWhtZWQ8L2ZpcnN0TmFtZT4NCiAgICAgIDxsYXN0TmFtZT5CZW91bWFpejwvbGFzdE5hbWU+DQogICANCjwvY3VzdG9tZXI+DQo8Y3VzdG9tZXI+DQogICA8Zmlyc3ROYW1lPkhhbXphPC9maXJzdE5hbWU+DQogICAgICA8bGFzdE5hbWU+QmVua2hhbGVkPC9sYXN0TmFtZT4NCiAgIA0KPC9jdXN0b21lcj4=</driver>
<fileName>INPUT</fileName>
</driver>
<driverEncoding>UTF-8</driverEncoding>
<engineOptions>
<name>RUNMODE</name>
<value>PRODUCTION</value>
</engineOptions>
<fileReturnRegEx>?</fileReturnRegEx>
<includeHeader>?</includeHeader>
<includeMessageFile>?</includeMessageFile>
<outputFile>
<directory>out</directory>
<fileName>sortie</fileName>
</outputFile>
<pubFile>PackageTest.pub</pubFile>
</EWSComposeRequest>
</eng:Compose>
</soapenv:Body>
</soapenv:Envelope>