使用php SOAP和WSDL的正确步骤是什么?

使用php SOAP和WSDL的正确步骤是什么?,php,web-services,soap,wsdl,Php,Web Services,Soap,Wsdl,我已经解决了许多问题和困惑,请参阅 在开发PHPSOAP服务时(第一次),我遇到了很多错误 让我画一个场景,以便更好地理解&在我的理解中 我手上有什么 web url(.asmx) 2个WSDL链接 ==>https:…/Schemas/Informationservice.WSDL ==>https:…/Schemas/Orderuploadservice.WSDL 3个证书文件(.pem和.CER和.PFX) 根据的参考,我创建了这个 p.S.此web服务位于ASP.net和SOA

我已经解决了许多问题和困惑,请参阅


在开发PHPSOAP服务时(第一次),我遇到了很多错误

让我画一个场景,以便更好地理解&在我的理解中

我手上有什么

  • web url(
    .asmx
  • 2个WSDL链接
    • ==>https:…/Schemas/Informationservice.WSDL
    • ==>https:…/Schemas/Orderuploadservice.WSDL
  • 3个证书文件(
    .pem
    .CER
    .PFX
根据的参考,我创建了这个

p.S.此web服务位于ASP.net和SOAP1.1上,因此请使用httpS运行此服务

下面是主要代码部分

  $x = new SoapClient(<wsdlink>, [
                                // 'local_cert' => '<cert>.pem',
                                // 'allow_self_signed' => true,
                                // 'cache_wsdl' => WSDL_CACHE_NONE,
                                'location' =>'https://192.168.xx.xx/wsdl/try.php',
                                'uri' =><other_wsdlink>,
                                'passphrase' => $passphrase,
                                'exceptions' => false,
                                'trace' => true,
                                'soap_version' => SOAP_1_1
                                //'connection_timeout'=>2000,
                                //'encoding'=> 'ISO-8859-1' // 'UTF-8'
                            ]);

2.当我取消对以上三行的评论时,会给出多个警告和致命错误 警告:SoapClient::SoapClient():

  - Unable to set private key file <cert>.pem
  - failed to create an SSL handle
  - Failed to enable crypto
  - (<wsdlink>):failed to open stream: operation failed
  - I/O warning : failed to load external entity <wsdlink>
我的疑问和困惑是:

  • 我是否需要在构造函数中同时设置
    soapClient
    soapServer

  • 我需要为证书文件设置一些额外的规则吗

  • $uri
    选项的作用是什么(这是必需的)以及发送请求或

  • 这是一个证书问题还是可能是系统或网络问题(UBUNTU 14.04),如果是,如何检查

  • 更新 更改许可证

     openssl pkcs12 -in certificatefile.PFX -out certfile.pem -nodes -clcerts  
    
    取消注释
    cert
    选项,并注释所有
    preg\u replace
    code from\uu doRequest方法

    但是现在出现了头球问题。我注意到我发送的请求正在被修剪或截断

    我发出的请求是


    上面的标题问题已修复,它是由于错误的
    uri
    值而生成的。这将是命名空间

    任何确保在PHP中获得正确类的简单方法都是使用它们提供一个命令行生成器,您可以使用您拥有的WSDL运行该生成器,它将为所有请求和响应以及最重要的服务生成一组PHP类

    在调用Web服务的类中,您可以执行以下操作:

    // Construct the service
    $service = new Service();
    // Construct the request
    $request = new RequestMethod();
    $request->element = "test";
    // Call the function
    $response = $service->callRequest($request);
    // process response
    die(var_dump($response));
    

    如果您使用的是框架之类的东西,您可能需要重构生成的类,但它为您提供了一个很好的起点。

    看起来您确实缺少了soapClient。我总是在我的构造函数中设置它var_dump($x->u getFunctions())重新运行函数列表。是否未看到任何注释,到目前为止没有响应?所有版主都不在工作吗?你能分享wsdl文件吗?您有权访问服务器日志吗?你能分享一下你在服务器端遇到的异常情况吗?你遇到了一个高级代表的问题:没有人能回答它:-)我自己在web服务上工作,但从来没有遇到过你的问题;如果没有可复制的案例,这将很难帮助。
      - Unable to set private key file <cert>.pem
      - failed to create an SSL handle
      - Failed to enable crypto
      - (<wsdlink>):failed to open stream: operation failed
      - I/O warning : failed to load external entity <wsdlink>
    
        ini_set('soap.wsdl_cache_enabled',0);
        ini_set('soap.wsdl_cache_ttl',0);
    
     openssl pkcs12 -in certificatefile.PFX -out certfile.pem -nodes -clcerts  
    
    <?xml version="1.0" encoding="utf-8"?>
            <soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
              <soap:Body>
                <addressVerificationRequest xmlns="urn:DCNZ.MSP.Wireline.Wholesale.Common">
                  <addressVerification>
                    <samId xmlns="urn:DCNZ.MSP.Wireline.Wholesale.Common">string</samId>
                    ...
                    <postalCode xmlns="urn:DCNZ.MSP.Wireline.Wholesale.Common">string</postalCode>
                  </addressVerification>
                </addressVerificationRequest>
              </soap:Body>
            </soap:Envelope>;
    
    <?xml version="1.0" encoding="UTF-8"?>  
    <SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns1="urn:DCNZ.MSP.Wireline.Wholesale.Messages">  
     <SOAP-ENV:Body><ns1:addressVerificationRequest/></SOAP-ENV:Body>
    </SOAP-ENV:Envelope>'
    
    // Construct the service
    $service = new Service();
    // Construct the request
    $request = new RequestMethod();
    $request->element = "test";
    // Call the function
    $response = $service->callRequest($request);
    // process response
    die(var_dump($response));