简体   繁体   English

使用PHP列出使用SOAP的Web服务中的信息

[英]Use PHP to list info from a Web Service that's using SOAP

I have never used SOAP before (and still wouldn't have if not needed) but I need to make an input search to list info (with the help of php or javascript) from a web service using SOAP and I have this Query , the XML Service Deschiption and the method address: 我之前从未使用过SOAP(如果不需要,仍然不会使用)但我需要使用SOAP从Web服务进行输入搜索以列出信息(借助php或javascript),我有这个查询XML Service Deschiption和方法地址:

{AdresaInterfata}?op= CautareDosare

And this method prototype: 而这个方法原型:

[WebMethod(Description = "Cautare dosare dupa numar, obiect, institutie")]
        public Dosar[] CautareDosare(
            string numarDosar,
            string obiectDosar,
            string numeParte,
            Institutie? institutie,
            DateTime? dataStart,
            DateTime? dataStop

            )

...and I basically don't know where to start or what to do to put these together. ......我基本上不知道从哪里开始或者做些什么来把它们放在一起。 This web service contains info of all the justice files and their status/updates and so on. 此Web服务包含所有正义文件及其状态/更新等信息。 An example of it working is on their own website. 它的一个例子是在他们自己的网站上。

Happily for you, this is a problem that has been solved by many before you, so you can benefit from their work. 令你高兴的是,这是许多人在你之前解决的问题,所以你可以从他们的工作中受益。

I have had a lot of success with this project: https://github.com/wsdl2phpgenerator/wsdl2phpgenerator 我在这个项目上取得了很大的成功: https//github.com/wsdl2phpgenerator/wsdl2phpgenerator

(packaged for composer here: https://packagist.org/packages/wsdl2phpgenerator/wsdl2phpgenerator ) (这里为作曲家打包: https//packagist.org/packages/wsdl2phpgenerator/wsdl2phpgenerator

It has a class that you can use to generate SOAP client classes in PHP from a WSDL. 它有一个类,您可以使用它从WSDL生成PHP中的SOAP客户端类。 It basically writes code for you that you can just use to make your SOAP calls, effectively abstracting this whole problem away. 它基本上为您编写代码,您可以使用它来进行SOAP调用,从而有效地抽象出整个问题。 They have pretty good documentation as well. 他们也有很好的文档。 If you're looking for a starting point, that might be a good one as it does a lot of work for you. 如果你正在寻找一个起点,这可能是一个很好的起点,因为它为你做了很多工作。

If you'd rather start more low level, you can check out PHP's SoapClient class: http://php.net/manual/en/class.soapclient.php 如果你想开始更低级别,你可以查看PHP的SoapClient类: http//php.net/manual/en/class.soapclient.php

Wsdl2Php Example Wsdl2Php示例

Here is a script I threw together that generates the needed code: 这是一个我扔在一起生成所需代码的脚本:

<?php
// generate.php

// Include composer autoloader to pull in libraries:
require 'vendor/autoload.php';

// Generate client code for the web service:
$generator = new \Wsdl2PhpGenerator\Generator();
$generator->generate(
    new \Wsdl2PhpGenerator\Config(array(
        'inputFile' => 'http://portalquery.just.ro/query.asmx?WSDL',
        'outputDir' => '/path/for/generated/code'
    ))
);

I then ran that script from the command line, and then went to "/path/for/generated/code" to find the generated classes. 然后我从命令行运行该脚本,然后转到“/ path / for / generated / code”以查找生成的类。

From there I created the following script: 从那里我创建了以下脚本:

<?php
// This line disables the SOAP cache.  This should be removed for production.
ini_set("soap.wsdl_cache_enabled", "0");

// Pull in generated class autoloader:
require '/path/for/generated/code/autoload.php';

$query = new Query();
$dateStart = new DateTime('2015-05-01');
$dateStop = new DateTime('2015-05-02');

// This would be a lot easier if I knew Romanian!
$cautareDosare = new CautareDosare("","","",Institutie::CurteadeApelBRASOV,$dateStart,$dateStop);

$results  = $query->CautareDosare($cautareDosare);

?>
<html>
  <body>
    <pre>
<?php var_export($results); ?>
    </pre>
  </body>
</html>

Which yielded the following results: 这产生了以下结果:

CautareDosareResponse::__set_state(array(
   'CautareDosareResult' => 
  ArrayOfDosar::__set_state(array(
     'Dosar' => 
    array (
      0 => 
      Dosar::__set_state(array(
         'parti' => 
        ArrayOfDosarParte::__set_state(array(
           'DosarParte' => 
          array (
            0 => 
            DosarParte::__set_state(array(
               'nume' => 'NEGOIŢĂ LAURA MARIA',
               'calitateParte' => 'Contestator',
            )),
          ),
        )),
         'sedinte' => 
        ArrayOfDosarSedinta::__set_state(array(
           'DosarSedinta' => 
          array (
            0 => 
            DosarSedinta::__set_state(array(
               'complet' => 'JDL(C)3',
               'data' => '2015-05-04T00:00:00',
               'ora' => '10:00',
               'solutie' => 'Respins',
               'solutieSumar' => '
    Respinge contestaţia declarată de inculpata Negoiţă Laura Maria împotriva încheierii de şedinţă din data de 1 mai 2015 pronunţată de Judecătorul de Drepturi şi Libertăţi de la Tribunalul pentru Minori şi Familie Braşov, în dosar nr. 359/1372/2014, pe care o menţine.
    Obligă inculpata să plătească statului suma de 100 lei cu titlu de cheltuieli judiciare.
    Definitivă.
    Pronunţată în camera de consiliu, azi 4 mai 2015.
',
               'dataPronuntare' => '2015-05-04T00:00:00',
               'documentSedinta' => 'incheierefinaladezinvestire',
               'numarDocument' => '48/2015',
               'dataDocument' => '2015-05-04T00:00:00',
            )),
          ),
        )),
         'caiAtac' => NULL,
         'numar' => '229/64/2015',
         'numarVechi' => '',
         'data' => '2015-05-01T18:29:00',
         'institutie' => 'CurteadeApelBRASOV',
         'departament' => 'Secţia Penală',
         'categorieCaz' => 'Penal',
         'stadiuProcesual' => 'ContestaţieNCPP',
         'obiect' => 'audierea inculpatului arestat în lipsă (art.231 NCPP)',
         'dataModificare' => '2015-05-04T15:01:24.613',
         'categorieCazNume' => 'Penal',
         'stadiuProcesualNume' => 'Contestaţie(NCPP)',
      )),
      1 => 
      Dosar::__set_state(array(
         'parti' => 
        ArrayOfDosarParte::__set_state(array(
           'DosarParte' => 
          array (
            0 => 
            DosarParte::__set_state(array(
               'nume' => 'VULCAN HORAÅ¢IU-ADRIAN',
               'calitateParte' => 'Contestator Inculpat',
            )),
            1 => 
            DosarParte::__set_state(array(
               'nume' => 'HANGHICEL MARIUS-FLORIN',
               'calitateParte' => 'Contestator Inculpat',
            )),
            2 => 
            DosarParte::__set_state(array(
               'nume' => 'PÃŽRÅ¢AC ANDREI',
               'calitateParte' => 'Contestator Inculpat',
            )),
            3 => 
            DosarParte::__set_state(array(
               'nume' => 'URDEA EMIL',
               'calitateParte' => 'Intimat Inculpat',
            )),
            4 => 
            DosarParte::__set_state(array(
               'nume' => 'PARCHETUL DE PE LÂNGĂ ÎNALTA CURTE DE CASAŢIE ŞI JUSTIŢIE - D.I.I.C.O.T. - SERVICIUL TERITORIAL BRAŞOV',
               'calitateParte' => 'Contestator',
            )),
          ),
        )),
         'sedinte' => 
        ArrayOfDosarSedinta::__set_state(array(
           'DosarSedinta' => 
          array (
            0 => 
            DosarSedinta::__set_state(array(
               'complet' => 'JDL(C)10',
               'data' => '2015-05-04T00:00:00',
               'ora' => '9:00',
               'solutie' => 'Admis',
               'solutieSumar' => ' În baza art. 204 Cod procedură penală şi art. 425 indice 1 alineat 7 punct 2 litera a Cod de procedură penală admite contestaţia formulată de Parchetul de pe lângă Înalta Curte de Casaţie şi Justiţie - DIICOT- Serviciul Teritorial Braşov împotriva încheierii nr. 46/UP/30.04.2015 pronunţată de judecătorul de drepturi şi libertăţi din cadrul Tribunalului Braşov în dosarul penal nr. 1820/62/2015, pe care o desfiinţează cu privire la soluţionarea propunerii de arestare preventivă în ceea ce-l priveşte pe inculpatul Urdea Emil.
Rejudecând în aceste limite:
În baza art. 204 alineat 10 şi art. 226 Cod de procedură penală admite propunerea de arestare preventivă formulată de Parchetul de pe lângă Înalta Curte de Casaţie şi Justiţie - DIICOT- Serviciul Teritorial Braşov şi în consecinţă, în baza art. 202 alineat 1, 3 şi 4 litera e Cod de procedură penală, art. 223 alineat 2 teza a II a Cod de procedură penală dispune arestarea preventivă pe o durată de 30 de zile, începând cu data punerii în executare a mandatului de arestare preventivă, a inculpatului Urdea Emil. Dispune emiterea mandatului de arestare preventivă a inculpatului Urdea Emil.
În baza art. 425 indice 1 alineat 7 punct 1 litera b Cod de procedură penală respinge ca nefondate contestaţiile formulate de inculpaţii Vulcan Horaţiu Adrian, Pîrţac Andrei şi Hanghicel Marius Florin împotriva încheierii nr. 46/UP/30.04.2015 pronunţată de judecătorul de drepturi şi libertăţi din cadrul Tribunalului Braşov în dosarul penal nr. 1820/62/2015 şi menţine dispoziţiile referitoare la aceşti inculpaţi.
În baza art. 275 alineat 2 Cod de procedură penală obligă inculpaţii  Vulcan Horaţiu Adrian, Pîrţac Andrei şi Hanghicel Marius Florin la plata fiecare a sumei de 100 de lei reprezentând cheltuieli judiciare avansate de stat, restul cheltuielilor avansate de stat rămânând în sarcina acestuia.
Definitivă.
    Pronunţată în şedinţă camerei de consiliu azi, 04.05.2015
',
               'dataPronuntare' => '2015-05-04T00:00:00',
               'documentSedinta' => 'incheierefinaladezinvestire',
               'numarDocument' => '50/2015',
               'dataDocument' => '2015-05-04T00:00:00',
            )),
          ),
        )),
         'caiAtac' => 
        ArrayOfDosarCaleAtac::__set_state(array(
           'DosarCaleAtac' => 
          array (
            0 => 
            DosarCaleAtac::__set_state(array(
               'dataDeclarare' => '2015-04-30T00:00:00',
               'parteDeclaratoare' => '',
               'tipCaleAtac' => 'Contestaţie(NCPP)',
            )),
            1 => 
            DosarCaleAtac::__set_state(array(
               'dataDeclarare' => '2015-04-30T00:00:00',
               'parteDeclaratoare' => ' HANGHICEL MARIUS-FLORIN,  PÃŽRÅ¢AC ANDREI,  VULCAN HORAÅ¢IU-ADRIAN, ',
               'tipCaleAtac' => 'Contestaţie(NCPP)',
            )),
          ),
        )),
         'numar' => '1820/62/2015',
         'numarVechi' => '',
         'data' => '2015-05-01T15:13:00',
         'institutie' => 'CurteadeApelBRASOV',
         'departament' => 'Secţia Penală',
         'categorieCaz' => 'Penal',
         'stadiuProcesual' => 'ContestaţieNCPP',
         'obiect' => 'luarea măsurii arestării preventive propusă de DNA/DIICOT (art.223 NCPP)',
         'dataModificare' => '2015-06-15T10:10:12.637',
         'categorieCazNume' => 'Penal',
         'stadiuProcesualNume' => 'Contestaţie(NCPP)',
      )),
    ),
  )),
))    

try to explore this link, to Connect to the Web Service API using PHP 尝试探索此链接,使用PHP连接到Web服务API

  http://help.exacttarget.com/en/technical_library/web_service_guide/getting_started_developers_and_the_exacttarget_api/connecting_to_the_api_using_php/

and in place of the below url 并代替以下网址

$wsdl = 'https://webservice.exacttarget.com/etframework.wsdl';

replace with 用。。。来代替

$wsdl = 'http://portalquery.just.ro/query.asmx?WSDL';

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM