简体   繁体   English

尝试通过php使用soap返回“无法连接到主机”错误。 使用SoapUi的相同wsdl文件可以正常工作。 我想念什么?

[英]Trying to use soap through php returns a “Could not connect to host” error. Same wsdl file using SoapUi works fine. What am I missing?

So I have a WSDL file that I use in php to get a specific response from <soap:address location="http://212.205.47.226:9003"/> 所以我有一个WSDL文件,我在php中使用它来从<soap:address location="http://212.205.47.226:9003"/>获得特定响应

That is defined in the wsdl file named PELVG02.wsdl. 这在名为PELVG02.wsdl的wsdl文件中定义。 It's contents are: 它的内容是:

    <?xml version="1.0" encoding="UTF-8" standalone="no" ?>
<definitions name="PELVG02" targetNamespace="/PELVG02" xmlns="http://schemas.xmlsoap.org/wsdl/" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:tns="/PELVG02" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:wsi="http://ws-i.org/schemas/conformanceClaim/" xmlns:xs="http://www.w3.org/2001/XMLSchema">
    <!-- Micro Focus NetExpress generated WSDL document-->
    <types>
      <schema elementFormDefault="qualified" targetNamespace="/PELVG02" xmlns="http://www.w3.org/2001/XMLSchema" xmlns:tns="/PELVG02">
        <element name="READ">
          <complexType>
            <sequence>
              <element name="pel_user_code" type="string"/>
              <element name="pel_user_pass" type="string"/>
              <element name="pel_apost_code" type="string"/>
              <element name="pel_paral_name" type="string"/>
              <element name="pel_paral_address" type="string"/>
              <element name="pel_paral_area" type="string"/>
              <element name="pel_paral_tk" type="string"/>
              <element name="pel_paral_thl_1" type="string"/>
              <element name="pel_paral_thl_2" type="string"/>
              <element name="pel_service" type="string"/>
              <element name="pel_baros" type="string"/>
              <element name="pel_temaxia" type="string"/>
              <element name="pel_paral_sxolia" type="string"/>
              <element name="pel_sur_1" type="string"/>
              <element name="pel_sur_2" type="string"/>
              <element name="pel_sur_3" type="string"/>
              <element name="pel_ant_poso" type="string"/>
              <element name="pel_ant_poso1" type="string"/>
              <element name="pel_ant_poso2" type="string"/>
              <element name="pel_ant_poso3" type="string"/>
              <element name="pel_ant_poso4" type="string"/>
              <element name="pel_ant_date1" type="string"/>
              <element name="pel_ant_date2" type="string"/>
              <element name="pel_ant_date3" type="string"/>
              <element name="pel_ant_date4" type="string"/>
              <element name="pel_asf_poso" type="string"/>
              <element name="pel_ref_no" type="string"/>
            </sequence>
          </complexType>
        </element>
        <element name="READResponse">
          <complexType>
            <sequence>
              <element name="st_flag" type="integer"/>
              <element name="st_title" type="string"/>
              <element name="vg_code" type="string"/>
              <element name="return_vg" type="string"/>
              <element name="epitagh_vg" type="string"/>
            </sequence>
          </complexType>
        </element>
      </schema>
    </types>
    <message name="READInput">
      <part element="tns:READ" name="parameters"/>
    </message>
    <message name="READOutput">
      <part element="tns:READResponse" name="parameters"/>
    </message>
    <portType name="PELVG02">
      <operation name="READ">
        <input message="tns:READInput"/>
        <output message="tns:READOutput"/>
      </operation>
    </portType>
    <binding name="PELVG02" type="tns:PELVG02">
      <soap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"/>
      <operation name="READ">
        <soap:operation soapAction=""/>
        <input>
          <soap:body use="literal"/>
        </input>
        <output>
          <soap:body use="literal"/>
        </output>
      </operation>
    </binding>
    <service name="PELVG02">
      <port binding="tns:PELVG02" name="PELVG02">
        <documentation>
          <wsi:Claim conformsTo="http://ws-i.org/profiles/basic/1.0"/>
        </documentation>
        <soap:address location="http://212.205.47.226:9003"/>
      </port>
    </service>
  </definitions>

That file when fed into SoapUI works just fine. 将该文件输入SoapUI后就可以正常工作。 I can send and receive data. 我可以发送和接收数据。 When I try to do the same using php I get a "Could not connect to host" error. 当我尝试使用php执行相同操作时,出现“无法连接到主机”错误。

Here is a sample php that produces that error: 这是产生该错误的示例php:

    <?php 
//Create the client object
try
{
    $soapclient = new SoapClient('./PELVG02.wsdl');

    //Use the functions of the client, the params of the function are in 
    //the associative array
    $pel = array('pel_user_code' => '9999999', 'pel_user_pass' => '9999999', 'pel_apost_code' => '999999999', 'pel_paral_name' => 'DOKIMI', 'pel_paral_address' => 'DOKIMI 13', 'pel_paral_area' => 'THESSALONIKI', 'pel_paral_tk' => '54646', 'pel_paral_thl_1' => '6973262626', 'pel_paral_thl_2' => '', 'pel_service' => '', 'pel_baros' => '12.50', 'pel_temaxia' => '', 'pel_paral_sxolia' => 'DOKIMI SXOLIA', 'pel_sur_1' => '', 'pel_sur_2' => '', 'pel_sur_3' => '', 'pel_ant_poso' => '', 'pel_ant_poso1' => '', 'pel_ant_poso2' => '', 'pel_ant_poso3' => '', 'pel_ant_poso4' => '', 'pel_ant_date1' => '', 'pel_ant_date2' => '', 'pel_ant_date3' => '', 'pel_ant_date4' => '', 'pel_asf_poso' => '', 'pel_ref_no' => '');

    $response = $soapclient->READ($pel);

    var_dump($response);
}
catch(SoapFault $e)
{
    var_dump($e);
}
?>

I should receive a simple response in the $response variable that contains a mix of Numbers and letters. 我应该在$ response变量中收到一个简单的响应,该变量包含数字和字母。

Here is the response I get in the soapUI program in XML to have aa sample: 这是我在XML的soapUI程序中得到的响应,并有一个示例:

<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
   <SOAP-ENV:Body>
      <ns0:READResponse xmlns:ns0="/PELVG02">
         <ns0:st_flag>0</ns0:st_flag>
         <ns0:st_title/>
         <ns0:vg_code>NZ000034401GR</ns0:vg_code>
         <ns0:return_vg/>
         <ns0:epitagh_vg/>
      </ns0:READResponse>
   </SOAP-ENV:Body>
</SOAP-ENV:Envelope>

Could you please help me figure out why I can't get the php to work? 您能帮我弄清楚为什么我无法使PHP正常工作吗? What am I missing there? 我在那里想念什么?

Thanx in advance. 提前感谢。

Edit: you can feed the following data in sourceui to get results and verify that the file PELVG02.wsdl I have pasted above works: 编辑:您可以在sourceui中提供以下数据以获取结果并验证我上面粘贴的文件PELVG02.wsdl:

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:pel="/PELVG02">
   <soapenv:Header/>
   <soapenv:Body>
      <pel:READ>
         <pel:pel_user_code>9999999</pel:pel_user_code>
         <pel:pel_user_pass>9999999</pel:pel_user_pass>
         <pel:pel_apost_code>999999999</pel:pel_apost_code>
         <pel:pel_paral_name>DOKIMI</pel:pel_paral_name>
         <pel:pel_paral_address>DOKIMI 13</pel:pel_paral_address>
         <pel:pel_paral_area>THESSALONIKI</pel:pel_paral_area>
         <pel:pel_paral_tk>54646</pel:pel_paral_tk>
         <pel:pel_paral_thl_1>6973206899</pel:pel_paral_thl_1>
         <pel:pel_paral_thl_2></pel:pel_paral_thl_2>
         <pel:pel_service></pel:pel_service>
         <pel:pel_baros>12.50</pel:pel_baros>
         <pel:pel_temaxia>1</pel:pel_temaxia>
         <pel:pel_paral_sxolia>DOKIMI SXOLIA</pel:pel_paral_sxolia>
         <pel:pel_sur_1></pel:pel_sur_1>
         <pel:pel_sur_2></pel:pel_sur_2>
         <pel:pel_sur_3></pel:pel_sur_3>
         <pel:pel_ant_poso></pel:pel_ant_poso>
         <pel:pel_ant_poso1></pel:pel_ant_poso1>
         <pel:pel_ant_poso2></pel:pel_ant_poso2>
         <pel:pel_ant_poso3></pel:pel_ant_poso3>
         <pel:pel_ant_poso4></pel:pel_ant_poso4>
         <pel:pel_ant_date1></pel:pel_ant_date1>
         <pel:pel_ant_date2></pel:pel_ant_date2>
         <pel:pel_ant_date3></pel:pel_ant_date3>
         <pel:pel_ant_date4></pel:pel_ant_date4>
         <pel:pel_asf_poso></pel:pel_asf_poso>
         <pel:pel_ref_no></pel:pel_ref_no>
      </pel:READ>
   </soapenv:Body>
</soapenv:Envelope>

Edit: I installed MAMP on my pc and it seems that the php code works through MAMP or XAMPP. 编辑:我在我的电脑上安装了MAMP,看来php代码通过MAMP或XAMPP可以工作。

Then it hit me! 然后打我! The firewall... I allowed outgoing connections to tcp|out|d=9003|d=212.205.47.226 防火墙...我允许传出连接到tcp|out|d=9003|d=212.205.47.226

from csf.allow and the soap function worked. 从csf.allow和soap功能起作用。 I guess we can call that issue resolved :D 我想我们可以称该问题已解决:D

I installed MAMP on my pc and it seems that the php code works through MAMP or XAMPP. 我在我的电脑上安装了MAMP,看来php代码通过MAMP或XAMPP起作用。

Then it hit me! 然后打我! The firewall... I allowed outgoing connections to tcp|out|d=9003|d=212.205.47.226 防火墙...我允许传出连接到tcp | out | d = 9003 | d = 212.205.47.226

from csf.allow and the soap function worked. 从csf.allow和soap功能起作用。 I guess we can call that issue resolved :D 我想我们可以称该问题已解决:D

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

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