【问题标题】:PHP SOAP web service callPHP SOAP Web 服务调用
【发布时间】:2010-08-05 19:05:52
【问题描述】:

我先说我以前从未使用过 SOAP。

无论如何,这是我正在尝试创建的代码。

<soapenv:Body> 
<Circuits xmlns="http://www.qpricer.com/Services/Pricing"> 
<Circuit bandwidth="DS-3" port-billing-type="Flat" product="Dedicated Voice" term="1-Year"> 
<ns1:Loop npanxx="212255" xmlns:ns1="http://www.qpricer.com/Schema/Pricing"> 
<ns1:Address city="MANHATTAN" postal-code="10011" state="NY" street="111 8 AV FLR 1"/> 
</ns1:Loop> 
</Circuit> 
</Circuits> 
</soapenv:Body>

标题已经到位。我可以打电话给服务。

我有的是这个

//Make the call  
$result = $client->Price('Circuits',
        array(
        'Circuit'           =>  array(
        'product'           =>  'Dedicated Voice',
        'port-billing-type' => 'flat',
        'term'              =>  '1-Year',
        'bandwidth'         =>  'DS-3'
        ),

        'Loop'              =>  array(
        'npanxx'            =>  '212255'
        ),

        'Address'           =>  array(
        'street'            =>  '111 8 AV FLR 1',
        'city'              =>  'MANHATTAN',
        'state'             =>  'NY',
        'postal-code'       =>  '10011')
        ));

// Display the result  
print_r($client->__getLastRequest());  
print_r($result);

【问题讨论】:

    标签: php soap soap-client nusoap


    【解决方案1】:

    这行得通吗:

    $result = $client->Price('Circuits',
        array(
        'Circuit'           =>  array(
            '_'                 => array(
                'Loop'              =>  array(
                    '_' => '',
                    'npanxx'            =>  '212255'
                ),
                'Address'           =>  array(
                    '_' => '',
                    'street'            =>  '111 8 AV FLR 1',
                    'city'              =>  'MANHATTAN',
                    'state'             =>  'NY',
                   'postal-code'       =>  '10011'
                ) 
             ),
            'product'           =>  'Dedicated Voice',
            'port-billing-type' => 'flat',
            'term'              =>  '1-Year',
            'bandwidth'         =>  'DS-3'
            )
        ));
    

    '_' 似乎没有记录但可以使用。如果它不起作用,请尝试http://www.php.net/manual/en/soapvar.soapvar.php 的 cmets。

    【讨论】:

    • 不幸的是,不。仍然是同样的错误。 " 致命错误:未捕获的 SoapFault 异常:[soap:Client] QPricer.API.Common.Model.ApiException:在定价请求中未检测到电路。检查您的 XML 命名空间,也许?在 QPricer.API.QPricer.Price(Circuitscircuits) 中C:\wamp\www\soap.php:79 堆栈跟踪:#0 [内部函数]:SoapClient->__call('Price', Array) #1 C:\wamp\www\soap.php(79):SoapClient ->Price('Circuits', Array) #2 {main} 在第 79 行的 C:\wamp\www\soap.php 中抛出"
    • 啊,那么它可能只适用于简单类型。您是否尝试过我最后链接的soapvar示例(查看cmets)?生成的请求正文是什么?
    • 我确实尝试了第二个示例。它返回了这个。 “SOAP 故障:QPricer.API.Common.Model.ApiException:在定价请求中未检测到电路。检查您的 XML 命名空间,也许?在 QPricer.API.QPricer.Price(电路电路)
      schemas.xmlsoap.org/soap/envelope" xmlns:ns1="qpricer.com/Services/Pricing" xmlns:ns2="Identity">
      我的令牌在这里 :):token>
      "
    • 看起来它并没有完全发送 xml 文档的其余部分。嗯。
    • 好吧,在进一步研究这个之后,我几乎可以让它工作了。我的标题显然出现错误。这是他们需要的。 "schemas.xmlsoap.org/soap/envelope" xmlns:pric="qpricer.com/Services/Pricing" xmlns:pric1="qpricer.com/Schema/Pricing">
      "
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2013-12-05
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2023-04-08
    相关资源
    最近更新 更多