我一直试图用php从我的nginx服务器对asp.net webservice进行soap调用。当前的php版本是5.5。我们正在与之通信的服务使用https,而(出于测试目的)我们的服务器目前使用http。他们在防火墙后面,相关的ip地址已经被列入白名单。我使用soapclient内置的php来发出请求。当我在浏览器中访问wsdl链接时,或者如果我在php中打印出来,我可以看到xml,这样我就可以确认该部分正在工作。我尝试使用SoapUI,但它们不支持SNI。我已经创建了一个ssl密钥,web服务方已经签署了,然后我将它与我的私钥结合到一个。pfx证书中,这样我就可以用它来创建一个帐户。当我试图创建一个soapcall帐户时,我得到错误soapfault:forbidden
下面是我创建soapclient的代码://页面顶部设置
ini_set("soap.wsdl_cache_enabled", "0");
ini_set('default_socket_timeout', 180);
$this->options = array(
'local_cert'=> file_get_contents($this->smartcard_cert),
'passphrase'=> $this::pass,
'trace' => 1,
'exceptions' => 1,
'keep_alive' => 0,
'connection_timeout' => 20
);
$this->soap = new SoapClient($this::protected_wsdl, $this->options);
这是我调用的函数:
public function create_current_acccount_get($reference = 233423) {
$values = $this->transaction_handler->createCurrentAccount($reference);
try {
$response = $this->soap->CreateCurrentAccount($values);
}
catch(Exception $e){
$response = $e->getMessage();
}
log_message('error', print_r("code4554 ".$response, TRUE));
$this->response($response);
}
我不能显示xml,因为它是机密的。我知道nginx使用。pem而不是。pfx,但web服务只接受。pfx。
如果有人知道为什么禁止soapfault是原因,我将永远感激,因为这已经困扰了我4天了,我还没能想出一个解决方案。
https://github.com/goetas-webservices/soap-client是完全PHP SOAP客户端,不依赖于来自PHP的ext-soap
。
它已经支持PSR7,多客户端,并允许通过IDE生成类型提示类。
https://github.com/goetas-webservices/soap-client-demo是一个演示项目,它允许您查看如何使用客户端来使用通用SOAP web服务。
由于是多客户端,您可以使用Guzzle(或任何https://github.com/php-http兼容的客户端)选项来提供传输层