douba3975 2012-08-17 06:16
浏览 43
已采纳

在PHP中使用SOAP寻求帮助[关闭]

I work in PHP, but never worked with things like SOAP. But today my managaer told me to fetch request from following SOAP request. As I don't know what is SOAP and what it's used for and even how to use it in my page. Can someone please tell me how can I make request a request from this sample request? Thanks. I tried searching google, but no relevant results were found.

POST /TestService/Service.asmx HTTP/1.1
Host: 123.12.12.123
Content-Type: text/xml; charset=utf-8
Content-Length: length
SOAPAction: "http://abc.com/Mobile"

<?xml version="1.0" encoding="utf-8"?>
<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:Body>
    <Mobile xmlns="http://abc.com/">
      <str>string</str>
    </Mobile>
  </soap:Body>
</soap:Envelope>

length and string are placeholders.

  • 写回答

2条回答 默认 最新

  • download20151010 2012-08-17 07:01
    关注

    Here is a very useful library, go to this page and download it: http://sourceforge.net/projects/nusoap/files/

    Here's one of the examples provided by the developers:

    require_once('lib/nusoap.php');
    $proxyhost = isset($_POST['proxyhost']) ? $_POST['proxyhost'] : '';
    $proxyport = isset($_POST['proxyport']) ? $_POST['proxyport'] : '';
    $proxyusername = isset($_POST['proxyusername']) ? $_POST['proxyusername'] : '';
    $proxypassword = isset($_POST['proxypassword']) ? $_POST['proxypassword'] : '';
    $client = new soapclient('http://www.xignite.com/xquotes.asmx?WSDL', true,
                            $proxyhost, $proxyport, $proxyusername, $proxypassword);
    $err = $client->getError();
    if ($err) {
        echo '<h2>Constructor error</h2><pre>' . $err . '</pre>';
    }
    // Doc/lit parameters get wrapped
    $param = array('Symbol' => 'IBM');
    $result = $client->call('GetQuickQuotes', array('parameters' => $param), '', '', false, true);
    // Check for a fault
    if ($client->fault) {
        echo '<h2>Fault</h2><pre>';
        print_r($result);
        echo '</pre>';
    } else {
        // Check for errors
        $err = $client->getError();
        if ($err) {
            // Display the error
            echo '<h2>Error</h2><pre>' . $err . '</pre>';
        } else {
            // Display the result
            echo '<h2>Result</h2><pre>';
            print_r($result);
            echo '</pre>';
        }
    }
    echo '<h2>Request</h2><pre>' . htmlspecialchars($client->request, ENT_QUOTES) . '</pre>';
    echo '<h2>Response</h2><pre>' . htmlspecialchars($client->response, ENT_QUOTES) . '</pre>';
    echo '<h2>Debug</h2><pre>' . htmlspecialchars($client->debug_str, ENT_QUOTES) . '</pre>';
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 素材场景中光线烘焙后灯光失效
  • ¥15 请教一下各位,为什么我这个没有实现模拟点击
  • ¥15 执行 virtuoso 命令后,界面没有,cadence 启动不起来
  • ¥50 comfyui下连接animatediff节点生成视频质量非常差的原因
  • ¥20 有关区间dp的问题求解
  • ¥15 多电路系统共用电源的串扰问题
  • ¥15 slam rangenet++配置
  • ¥15 有没有研究水声通信方面的帮我改俩matlab代码
  • ¥15 ubuntu子系统密码忘记
  • ¥15 保护模式-系统加载-段寄存器