如何修复php soapclient null值

时间:2013-07-24 23:33:11

标签: php soap soapui soap-client

如果我使用soap-ui,我可以获取数据,但我需要使用php soapclient并且它不会获取数据。

soap-ui上的输出

<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns1="http://webservice.bc/Interaction">
   <SOAP-ENV:Body>
      <ns1:QueryInteractionResponse>
         <productWarningArray>
            <ProductWarning>
               <Product>
                  <id>10008</id>
               </Product>
               <Color>
                  <id>4</id>
               </Color>
               <Value>Besinler, asetilsalisilik asitin emilimini yavaşlatır. Hızlı analjezi gerekliyse besinlerle birlikte verilmemelidir. Uzun süreli asetilsalisilik asit kullanımında, besinler, mide mukozasını korumaya yardımcı olur.</Value>
            </ProductWarning>
            <ProductWarning>
               <Product>
                  <id>10008</id>
               </Product>
               <Color>
                  <id>4</id>
               </Color>
               <Value>Besinler, psödoefedrinin emilimini yavaşlatır.</Value>
            </ProductWarning>
            <ProductWarning>
               <Product>
                  <id>2322</id>
               </Product>
               <Color>
                  <id>1</id>
               </Color>
               <Value>Besinler sildenafil absorbsiyonunu geciktirir.</Value>
            </ProductWarning>
         </productWarningArray>
      </ns1:QueryInteractionResponse>
   </SOAP-ENV:Body>
</SOAP-ENV:Envelope>

这是真的......

<Value>Besinler, asetilsalisilik asitin emilimini yavaşlatır. Hızlı analjezi gerekliyse besinlerle birlikte verilmemelidir. Uzun süreli asetilsalisilik asit kullanımında, besinler, mide mukozasını korumaya yardımcı olur.</Value>

但是当我使用php soapclient时

$client = new SoapClient("http://webservice.bc/web.wsdl", array(
                        'exceptions'=>true,
                        'cache_wsdl'=>WSDL_CACHE_NONE,
                        'compression' => SOAP_COMPRESSION_ACCEPT | SOAP_COMPRESSION_GZIP | 5,
                        'features' => SOAP_SINGLE_ELEMENT_ARRAYS,
                        'encoding'=>' utf-8'
                    //  'features' => SOAP_SINGLE_ELEMENT_ARRAYS

                ));
                $result = $client->QueryInteraction($requestData);
                echo "<pre>";
                print_r($result);

它没有得到价值......

Array
(
    [productWarningArray] => stdClass Object
        (
            [ProductWarning] => Array
                (
                    [0] => stdClass Object
                        (
                            [Product] => stdClass Object
                                (
                                    [id] => 10008
                                )

                            [Color] => stdClass Object
                                (
                                    [id] => 4
                                )

                            [Value] => stdClass Object
                                (
                                )

                        )

                    [1] => stdClass Object
                        (
                            [Product] => stdClass Object
                                (
                                    [id] => 10008
                                )

                            [Color] => stdClass Object
                                (
                                    [id] => 4
                                )

                            [Value] => stdClass Object
                                (
                                )

                        )

                    [2] => stdClass Object
                        (
                            [Product] => stdClass Object
                                (
                                    [id] => 2322
                                )

                            [Color] => stdClass Object
                                (
                                    [id] => 1
                                )

                            [Value] => stdClass Object
                                (
                                )

                        )

                )

        )

)

它的空...

[Value] => stdClass Object
                            (
                            )

我该如何解决问题?

谢谢......

1 个答案:

答案 0 :(得分:0)

解决了:)

在将值元素类型Paragraph更改为string时,在soap服务器端解决了问题。

<complexType name="ProductInteraction" >
            <sequence >
                <element name="Product"
                        type="self:Product" />

                <element name="Color"
                        type="self:Color" />

                <element name="Value"
                        type="self:Paragraph" />

            </sequence>
        </complexType>