我对 SOAP 很陌生(即不知道!)
客户要求我与现有的 SOAP 服务进行交互,该服务需要通过我的 SOAP header (简单的用户名和密码)完成身份验证
我有3种方法可以使用,
还活着 活着安全 更改用户详细信息
IsAlive 只返回 true,我可以调用它没问题
IsAliveSecure 通过适当的授权返回 true,但我无法让它返回 true。
基本上我需要发送以下请求:
POST /ripplecomprovisioning.asmx HTTP/1.1
Host: provisioning.example.ie
Content-Type: text/xml; charset=utf-8
Content-Length: length
SOAPAction: "http://www.blueface.ie/provisioning/IsAliveSecure"
<?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:Header>
<SoapAuthHeader xmlns="http://www.example.ie/provisioning/">
<Username>myusername</Username>
<Password>mypassword</Password>
</SoapAuthHeader>
</soap:Header>
<soap:Body>
<IsAliveSecure xmlns="http://www.example.ie/provisioning/" />
</soap:Body>
</soap:Envelope>
我的问题是如何在 php 中发送格式如上所示的请求?
这是我尝试过但没有成功的方法:
$soapClient = new SoapClient("https://provisioning.example.ie/ripplecomprovisioning.asmx?WSDL");
// Prepare SoapHeader parameters
$sh_param = array(
'Username' => 'myusername',
'Password' => 'mypassword');
$headers = new SoapHeader('ripplecomprovisioning', 'SoapAuthHeaders', $sh_param);
// Prepare Soap Client
$soapClient->__setSoapHeaders(array($headers));
$result = $soapClient->isAlive();
echo var_dump($result);
echo "<br /><br />";
$result = $soapClient->IsAliveSecure();
echo var_dump($result);
上面的输出如下:
object(stdClass)#3 (1) {
["IsAliveResult"]=>
bool(true)
}
<br /><br />
Fatal error: Uncaught SoapFault exception: [soap:Server] System.Web.Services.Protocols.SoapException: Server was unable to process request. ---> System.UnauthorizedAccessException: Attempted to perform an unauthorized operation.
at example.VoIP.Provisioning.RipplecomProvisioningServices.IsAliveSecure()
--- End of inner exception stack trace --- in /var/www/ripplecomweb/authentication/soap.php:20
Stack trace:
#0 [internal function]: SoapClient->__call('IsAliveSecure', Array)
#1 /var/www/ripplecomweb/authentication/soap.php(20): SoapClient->IsAliveSecure()
#2 {main}
thrown in /var/www/ripplecomweb/authentication/soap.php on line 20
如有任何帮助,我们将不胜感激。我不能失败!
谢谢
KV
最佳答案
好吧,如果我们能看到服务的 WSDL,那就容易多了。 但请尝试以下步骤:
1.检查 isAliveSecure 方法的 WSDL,看看您是否必须向它传递一些东西。
2.查看您发送的请求的真实情况:
var_dump($soapClient->__getLastRequest());
var_dump($soapClient->__getLastRequestHeaders());
(确保为这些方法使用选项 'trace' => TRUE 实例化 $soapClient,否则它们将不起作用 -> 请参阅 PHP manual ).
3.尝试通过命令行以您确定应该正确的形式手动发送请求,例如:
curl -v -k -d @/path/to/the/file/with/the/request/xml http://service_url
关于php - 在 php 中发送 SOAP 身份验证 header 的问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4313390/
我正在尝试使用ruby和Savon来使用网络服务。测试服务为http://www.webservicex.net/WS/WSDetails.aspx?WSID=9&CATID=2require'rubygems'require'savon'client=Savon::Client.new"http://www.webservicex.net/stockquote.asmx?WSDL"client.get_quotedo|soap|soap.body={:symbol=>"AAPL"}end返回SOAP异常。检查soap信封,在我看来soap请求没有正确的命名空间。任何人都可以建议我
给定这段代码defcreate@upgrades=User.update_all(["role=?","upgraded"],:id=>params[:upgrade])redirect_toadmin_upgrades_path,:notice=>"Successfullyupgradeduser."end我如何在该操作中实际验证它们是否已保存或未重定向到适当的页面和消息? 最佳答案 在Rails3中,update_all不返回任何有意义的信息,除了已更新的记录数(这可能取决于您的DBMS是否返回该信息)。http://ar.ru
我想安装一个带有一些身份验证的私有(private)Rubygem服务器。我希望能够使用公共(public)Ubuntu服务器托管内部gem。我读到了http://docs.rubygems.org/read/chapter/18.但是那个没有身份验证-如我所见。然后我读到了https://github.com/cwninja/geminabox.但是当我使用基本身份验证(他们在他们的Wiki中有)时,它会提示从我的服务器获取源。所以。如何制作带有身份验证的私有(private)Rubygem服务器?这是不可能的吗?谢谢。编辑:Geminabox问题。我尝试“捆绑”以安装新的gem..
我想为Heroku构建一个Rails3应用程序。他们使用Postgres作为他们的数据库,所以我通过MacPorts安装了postgres9.0。现在我需要一个postgresgem并且共识是出于性能原因你想要pggem。但是我对我得到的错误感到非常困惑当我尝试在rvm下通过geminstall安装pg时。我已经非常明确地指定了所有postgres目录的位置可以找到但仍然无法完成安装:$envARCHFLAGS='-archx86_64'geminstallpg--\--with-pg-config=/opt/local/var/db/postgresql90/defaultdb/po
尝试通过RVM将RubyGems升级到版本1.8.10并出现此错误:$rvmrubygemslatestRemovingoldRubygemsfiles...Installingrubygems-1.8.10forruby-1.9.2-p180...ERROR:Errorrunning'GEM_PATH="/Users/foo/.rvm/gems/ruby-1.9.2-p180:/Users/foo/.rvm/gems/ruby-1.9.2-p180@global:/Users/foo/.rvm/gems/ruby-1.9.2-p180:/Users/foo/.rvm/gems/rub
我希望我的UserPrice模型的属性在它们为空或不验证数值时默认为0。这些属性是tax_rate、shipping_cost和price。classCreateUserPrices8,:scale=>2t.decimal:tax_rate,:precision=>8,:scale=>2t.decimal:shipping_cost,:precision=>8,:scale=>2endendend起初,我将所有3列的:default=>0放在表格中,但我不想要这样,因为它已经填充了字段,我想使用占位符。这是我的UserPrice模型:classUserPrice回答before_val
我有一个表单,其中有很多字段取自数组(而不是模型或对象)。我如何验证这些字段的存在?solve_problem_pathdo|f|%>... 最佳答案 创建一个简单的类来包装请求参数并使用ActiveModel::Validations。#definedsomewhere,atthesimplest:require'ostruct'classSolvetrue#youcouldevencheckthesolutionwithavalidatorvalidatedoerrors.add(:base,"WRONG!!!")unlesss
我的最终目标是安装当前版本的RubyonRails。我在OSXMountainLion上运行。到目前为止,这是我的过程:已安装的RVM$\curl-Lhttps://get.rvm.io|bash-sstable检查已知(我假设已批准)安装$rvmlistknown我看到当前的稳定版本可用[ruby-]2.0.0[-p247]输入命令安装$rvminstall2.0.0-p247注意:我也试过这些安装命令$rvminstallruby-2.0.0-p247$rvminstallruby=2.0.0-p247我很快就无处可去了。结果:$rvminstall2.0.0-p247Search
由于fast-stemmer的问题,我很难安装我想要的任何rubygem。我把我得到的错误放在下面。Buildingnativeextensions.Thiscouldtakeawhile...ERROR:Errorinstallingfast-stemmer:ERROR:Failedtobuildgemnativeextension./System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/bin/rubyextconf.rbcreatingMakefilemake"DESTDIR="cleanmake"DESTDIR=
我有一些非常大的模型,我必须将它们迁移到最新版本的Rails。这些模型有相当多的验证(User有大约50个验证)。是否可以将所有这些验证移动到另一个文件中?说app/models/validations/user_validations.rb。如果可以,有人可以提供示例吗? 最佳答案 您可以为此使用关注点:#app/models/validations/user_validations.rbrequire'active_support/concern'moduleUserValidationsextendActiveSupport: