- android - RelativeLayout 背景可绘制重叠内容
- android - 如何链接 cpufeatures lib 以获取 native android 库?
- java - OnItemClickListener 不起作用,但 OnLongItemClickListener 在自定义 ListView 中起作用
- java - Android 文件转字符串
我正在尝试使用 PHP 的内置 soap 函数登录 API。我得到了这样的结果。
[LoginResult]=> false,
[ErrorMsg] => Login failed with the reason : The security object is invalid
这是 API 提供者的要求。
<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<soap:Body>
<Login xmlns="http://tempuri.org/Example/Service1">
<objSecurity>
<WebProviderLoginId>test</WebProviderLoginId>
<WebProviderPassword>test</WebProviderPassword>
<IsAgent>false</IsAgent>
</objSecurity>
<OutPut />
<ErrorMsg />
</Login>
</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="http://tempuri.org/Example/Service1">
<SOAP-ENV:Body>
<ns1:Login>
<objSecurity>
<WebProviderLoginId>test</WebProviderLoginId>
<WebProviderPassword>test</WebProviderPassword>
<IsAgent>false</IsAgent>
</objSecurity>
<OutPut/>
<ErrorMsg/>
</ns1:Login>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>
这是我用来发送请求的代码。
<?php
class objSecurity {
function objSecurity($s, $i, $f) {
$this->WebProviderLoginId = $s;
$this->WebProviderPassword = $i;
$this->IsAgent = $f;
}
}
class nextObject {
function nextObject($objSecurity) {
$this->objSecurity=$pobjSecurity;
$this->OutPut=NULL;
$this->ErrorMsg=NULL;
}
}
$url = 'http://example.com/sampleapi/test.asmx?WSDL';
$client = new SoapClient($url, array("soap_version" => SOAP_1_1,"trace" => 1));
$struct = new objSecurity('test', 'test', false);
$data = new nextObject($struct);
$soapstruct2 = new SoapVar($data, SOAP_ENC_OBJECT);
print_r(
$client->__soapCall(
"Login",
array(new SoapParam($soapstruct2, "inputStruct"))
)
);
echo $client->__getLastRequest();
?>
这些是我发现的差异。
在我的请求中 xmlns:xsi
丢失了。
要求以<soap:Envelope
开头, 但是我的请求以<SOAP-ENV:Envelope
开头.
还有一个额外的xmlns:ns1
在我的要求下。
& 函数名标签以ns1:
开头.
请帮助我将我的请求转换成要求的格式。
我对 SOAP 了解不多,我使用的是 PHP 5.3.13 版和 CakePHP 2.3.0。对不起,我的英语不好。
最佳答案
这是解决方案。 :)
<?php
$url = 'http://example.com/sampleapi/test.asmx?WSDL';
$client = new SoapClient($url, array("soap_version" => SOAP_1_1,"trace" => 1));
$user_param = array (
'WebProviderLoginId' => "test",
'WebProviderPassword' => "test",
'IsAgent' => false
);
$service_param = array (
'objSecurity' => $user_param,
"OutPut" => NULL,
"ErrorMsg" => NULL
);
print_r(
$client->__soapCall(
"Login",
array($service_param)
)
);
echo $client->__getLastRequest();
?>
&请求是:
<?xml version="1.0" encoding="UTF-8"?>
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns1="http://tempuri.org/Example/Service1">
<SOAP-ENV:Body>
<ns1:Login>
<ns1:objSecurity>
<ns1:WebProviderLoginId>test</ns1:WebProviderLoginId>
<ns1:WebProviderPassword>test</ns1:WebProviderPassword>
<ns1:IsAgent>false</ns1:IsAgent>
</ns1:objSecurity>
</ns1:Login>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>
感谢这个链接。 PHP SOAP Request not right
关于php - SOAP :信封 SOAP-ENV:信封 PHP,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14770898/
这个问题已经有答案了: env-cmd error failed to locate ./.env file in gatsby? (14 个回答) 已关闭 3 年前。 我正在学习 Gatsby 教程
我正在尝试使用 mgcv-package,但 mgcv::gam-function 只返回一条错误消息 Tmean = c(1,3,10,5,7) prec = c(300,500,700,600,5
在 Laravel 6 中 Documentation Application Key的第二段是这样写的 Typically, this string should be 32 characters
我试图在创建消息时传递 sns 主题。但根据创建的变量,arn 可能会有所不同。 例如,在环境变量中,我将有 3 个人及其主题。 john = arn:xxxxxxxx sally= arn:xxxx
我开始学习 Angular2,我发现在示例中它们覆盖了配置文件中的 process.env.NODE_ENV 和 process.env.ENV 变量。此代码来自 this example 的 web
我从头开始创建了一个Kotlin原生应用程序,我得到了上面的错误。我怎么才能解决这个问题呢?这是一款简单的“Hello World”应用程序。我有其他计算机,但该错误没有出现在那里。我认为这与科南没有
我有一个 Dockerfile,我在其中设置了一些环境变量(在我运行容器时使用)。一些环境变量依赖于以前的环境变量。当我可以替换为一个变量时,我想保持干爽并避免多次对环境变量的值进行硬编码。 在这个简
我正在学习 Docker 并面临将一个 env 变量的值替换为另一个 env 变量的问题。 这是我的 Dockerfile FROM ubuntu ENV var_env=Tarun ENV comm
我正在将一个项目从 Symfony 2.3 升级到 Symfony 3.4,我对 .env 和 .env.dist 文件之间的关系有点困惑。据我了解,它们之间的关系与Symfony2中paramete
在 python 中,有没有办法从特定的 .env 文件中检索 env 变量的值?例如,我有多个 .env 文件,如下所示: .env.a .env.a ... 我在 .env.b 中有一个名为 IN
我假设我的身份验证服务无法加载配置文件,从而导致错误。我正在关注 AUTH0 上的教程。这是链接 https://auth0.com/blog/real-world-angular-series-pa
我正在使用 base.env 作为我的几个 docker 服务的 env_file。在这个 base.env 中,我有几个部分的环境变量在整个文件中重复。例如,对于三个不同的环境变量,port 和 i
我正在尝试使用 values.SecretValue() 设置我的 aws 存储桶名称。要设置 Django 的媒体 url,我过去使用过: AWS_STORAGE_BUCKET_NAME = val
我通过从PowerShell运行$env:path ="$($env:path);."来“解决”一个问题。显然,它将当前目录添加到了我的路径。请添加到哪个路径变量?在我的环境变量对话框中,我会在哪里看
我有一个很长的自定义应用程序配置文件,用于在工作站上运行的应用程序,其中一些文本元素必须在系统之间手动更改。 这个脚本是为了让我的生活更轻松 - $content = Get-Content("C:\
因为我使用docker和docker-compose而不是Homestead和任何基于Vargrant的开发解决方案,所以我想避免与laravel在.env文件的使用上发生冲突。因此,我希望larav
当我尝试最后一个例子时 perlfaq5: How-do-I-count-the-number-of-lines-in-a-file?我收到一条错误消息。我应该怎样做才能使脚本正常工作? #!/usr
我试图理解为什么当我从我的 .env 文件中明确删除或注释掉它们时,我的 Docker 容器中的 env 变量仍然出现。我是 Docker 的新手,不知道这是预期的行为还是异常。 我的系统设置方式是,
我正在使用 PHP 和 Laravel 框架,我使用 .env 来设置我的环境变量。然后我从我的 PHP 环境调用 python 脚本,并将结果返回给 PHP。我的问题是,在 Python 中设置的默
我安装了 Anaconda 并创建了一个新环境(“dell_proj”)。然后我用我的新环境在 Pycharm 中创建了一个新项目。我的期望是我只能在这个项目中使用我通过 Conda 在特定环境中安装
我是一名优秀的程序员,十分优秀!