将PHP对象传递给SOAP

时间:2015-02-23 09:34:51

标签: php web-services soap wsdl

我正在尝试将php对象传递给SOAP服务

$client = new phpWebServiceClient('kursevi_servis', true); //service

$criteria = new stdClass();
            $criteria->limit = $limit;
            $criteria->offset = $offset;
            $criteria->search_term = $keyword;
                        var_dump($client->__getFunctions());

$client->pretraga_jedinica($criteria) 

在wsdl文件中我尝试

<xsd:complexType name="trazeneJedinice">
                <xsd:sequence>
                    <xsd:element name="trazeneJediniceObj"
                        type="tns:trazeneJediniceObjType" maxOccurs="unbounded"
                        minOccurs="0">
                    </xsd:element>
                    <xsd:element name="count_all" type="xsd:int"></xsd:element>
                </xsd:sequence>
            </xsd:complexType>

            <xsd:complexType name="trazeneJediniceObjType">
                <xsd:sequence>
                    <xsd:element name="limit" type="xsd:int"></xsd:element>
                    <xsd:element name="offset" type="xsd:int"></xsd:element>
                    <xsd:element name="keyword" type="xsd:string"></xsd:element>

                </xsd:sequence>
            </xsd:complexType>

但我收到错误

Fatal error: Uncaught SoapFault exception: [HTTP] Could not connect to host in C:\wamp\www\link-university\application\modules\lessons\controllers\lessons.php:296 Stack trace: #0 [internal function]: SoapClient->__doRequest('<?xml version="...', 'http://phpweb/l...', 'http://localhos...', 1, 0) #1 C:\wamp\www\link-university\application\modules\lessons\controllers\lessons.php(296): SoapClient->__call('pretraga_jedini...', Array) #2 C:\wamp\www\link-university\application\modules\lessons\controllers\lessons.php(296): phpWebServiceClient->pretraga_jedinica(Object(stdClass)) #3 [internal function]: Lessons->search() #4 C:\wamp\www\link-university\system\codeigniter\CodeIgniter.php(236): call_user_func_array(Array, Array) #5 C:\wamp\www\link-university\index.php(116): require_once('C:\wamp\www\lin...') #6 {main} thrown in C:\wamp\www\link-university\application\modules\lessons\controllers\lessons.php on line 296

当我使用var_dump soap

array (size=13)
  0 => string 'nizKurseva spisak_kurseva(string $spisak_kursevaRequest)' (length=56)
  1 => string 'trazeneJedinice pretraga_jedinica(UNKNOWN $pretraga_jedinicaRequest)' (length=68)
  2 => string 'nizModula moduli_kursa(int $moduli_kursaRequest)' (length=48)
  3 => string 'nizJedinica jedinice_modula(int $jedinice_modulaRequest)' (length=56)
  4 => string 'nizElemenata elementi_jedinice(int $elementi_jediniceRequest)' (length=61)
  5 => string 'JedinicaPodaci jedinica(int $jedinicaRequest)' (length=45)
  6 => string 'ModulPodaci modul(int $modulRequest)' (length=36)
  7 => string 'KursPodaci kurs(string $kursRequest)' (length=36)
  8 => string 'trazeniKursevi pretraga_kurseva(string $pretraga_kursevaRequest)' (length=64)
  9 => string 'TestPodaci test(int $testRequest)' (length=33)
  10 => string 'nizKurseva spisak_testova(string $spisak_testovaRequest)' (length=56)
  11 => string 'nizGrupa getGrupe(int $getGrupeRequest)' (length=39)
  12 => string 'jediniceByKurs jedinice_by_kurs(int $jedinice_by_kursRequest)' (length=61)

我有UNKNOW,也许在这里错误我不知道我做错了什么 所以在这一行

1 => string 'trazeneJedinice pretraga_jedinica(UNKNOWN $pretraga_jedinicaRequest)' (length=68)

1 个答案:

答案 0 :(得分:1)

疯狂猜测,无效/错误输入/丢失服务器名称?会解释您的无法连接错误。