解析wsdl:coudln' t url仅对我当前的肥皂中的URL负载?
我正在使用PHP中的肥皂量进行集成,但是经过这么多尝试和很多努力,我无法实现我应该做的事情,
实际上我正在整合银行肥皂请求,其中包含一些对启动的认证,但我得到了这一点一遍又一遍地错误。 IE
SOAP-ERROR: Parsing WSDL: Couldn't load from 'https://ibluatapig.indusind.com/app/uat/DomesticPayService1.wsdl' : failed to load external entity "https://ibluatapig.indusind.com/app/uat/DomesticPayService1.wsdl"
我只是在做简单的事情,
$soapClient = new SoapClient($url);
而且在执行此操作之后,我会在上面显示错误,但是当我使用其他任何肥皂URL进行同样的事情时,我会得到肥皂对象,从中我可以相应地获取数据 现在我感到困惑为什么会发生这种情况。该URL不合适,还是因为它是banking soapapi,因此它需要我必须通过的标头信息,但是根据PHP文档,首先我们创建了soapclient对象,然后我们有一个选项
$soapclient->__setSoapHeaders();
,所有方法,所有尝试,例如发送$ options ander and optect ander and y hoesd there and y ivery i我我已经尝试过的研究了,但失败了,
我已经尝试了这些尝试
$opts = array(
'http' => array(
'user_agent' => 'PHPSoapClient',
),
'ssl' => [
// set some SSL/TLS specific options
'verify_peer' => false,
'verify_peer_name' => false,
'allow_self_signed' => true,
],
);
$context = stream_context_create($opts);
$soapClientOptions = array(
'stream_context' => $context,
'cache_wsdl' => WSDL_CACHE_MEMORY,
);
,这些标头是
$headers = array(
'SOAPAction' => 'http://tempuri.org/IDomesticPayService/GetAccBalance',
'Content-type' => 'content-type: text/xml',
'X-IBM-Client-Secret' => 'client-secret',
'X-IBM-Client-ID' => 'client-id',
);
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
首先,让我们了解这里发生了什么。创建
soapclient
对象时,您需要指定有关要连接到的肥皂服务的一些详细信息。这些通常是在服务提供的配置文件中以称为WSDL的格式提供的。您要传递给构造函数的URL是该配置文件的URL。重要的是要理解的是,获取WSDL不是SOAP请求,它只是正常的HTTP Get请求,就像您使用Web浏览器或卷曲一样。因此,诸如“ SOAP标头”之类的肥皂特异性概念是无关紧要的,并且还没有“肥皂动作”可以指定(这是WSDL配置的一部分)。
在您的Postman请求中,您提供了两个自定义的HTTP标头“ X-ibm-client-secret”和“ X-ibm-client-id”,显然需要它们以访问此URL。您显示的PHP代码中没有任何地方尝试通过这些标题,因此您需要修复的内容。
Soapclient构造函数采用大量选项,这些选项不是很一致或直观,但是我刚刚重写手动页面记录所有内容。这里相关的是
stream_context
,它使您可以在所有HTTP请求中设置各种内容,我相信这包括获取初始的WSDL文件。其中包括标题',尽管它的名字使您可以设置HTTP标头的任何数字。如果这不起作用,则可以单独获取WSDL文件 - 记住发送这些自定义授权标题 - 然后通过本地文件名将其保存到Soapclient构造函数中。例如,只要您拥有
allow_url_fopen
option 已启用;因此,您可以做到这一点:可以使用卷曲或 guzzle 或任何其他HTTP库 - 只需查找设置自定义HTTP标头的示例即可。 (请记住,对于此步骤,您不需要任何特定于肥皂或WSDL的东西,而是您只需提出HTTP获取请求。)
Firstly, let's understand what's happening here. When you create a
SoapClient
object, you need to specify some details about the SOAP service to connect to. These are normally provided in a configuration file provided by the service, in a format called WSDL. The URL you're passing to the constructor is the URL of that configuration file.The important thing to understand here is that fetching the WSDL is not a SOAP request, it's just a normal HTTP GET request, like you'd make with a web browser, or curl. So SOAP-specific concepts like "SOAP headers" are irrelevant, and there is no "SOAP Action" to specify yet (that's part of what is configured by the WSDL once it's been fetched).
In your Postman request, you are providing two custom HTTP headers, 'X-IBM-Client-Secret' and 'X-IBM-Client-ID', which apparently are needed to access this URL. Nowhere in the PHP code you show have you attempted to pass those headers, so that's what you need to fix.
The SoapClient constructor takes a large number of options, which aren't very consistent or intuitive, but I have just rewritten the manual page to document them all. The one that's relevant here is
stream_context
, which lets you set various things to include on all HTTP requests, which I believe includes fetching the initial WSDL file. Among those is the an 'http' context option called 'header', which despite its name lets you set any number of HTTP headers.If this doesn't work, you can fetch the WSDL file separately - remembering to send those custom authorization headers - and then pass a local filename where you've saved it to the SoapClient constructor. For instance, the stream_context can also be used with
file_get_contents
, as long as you have theallow_url_fopen
option enabled; so you could do this:A similar thing could be done with curl, or Guzzle, or any other HTTP library - just look for an example of setting custom HTTP headers. (Remember that you don't need anything specific to SOAP or WSDL for this step, you're just making an HTTP GET request.)