首页 > 编程知识 正文

php获取post请求参数,php获取请求头数据

时间:2023-05-06 04:58:33 阅读:206395 作者:16

我正在尝试使用this WSDL将SOAP请求发送到新闻通讯服务.

这是我的PHP:

$client = new SoapClient($wsdl_url, array(

'login' => 'myusername',

'password' => 'mypassword',

'trace' => true

));

$client->AddSubscriber(

new SoapParam('MyFirstName', 'FirstName'),

new SoapParam('MyLastName', 'LastName'),

new SoapParam('myemail@someaddress.com', 'Email')

);

我得到了例外:

End element 'Body' from namespace 'schemas.xmlsoap.org/soap/envelope/' expected. Found element 'LastName' from namespace ''. Line 2, position 156.

以下是该服务对AddSubscriber的期望:

string

string

string

string

string

string

string

boolean

这是发送的内容:

MyLastName

myemail@someaddress.com

我对SOAP不太熟悉,并且一直到处都在寻找文档,但是我似乎无法为我的工作找到很好的参考.

任何指导将不胜感激!

谢谢.你能给我一个例子吗?我正在看PHP网站上的示例,该示例显示:

class SOAPStruct {

function SOAPStruct($s, $i, $f)

{

$this->varString = $s;

$this->varInt = $i;

$this->varFloat = $f;

}

}

$client = new SoapClient(null, array('location' => "http://localhost/soap.php",

'uri' => "http://test-uri/"));

$struct = new SOAPStruct('arg', 34, 325.325);

$soapstruct = new SoapVar($struct, SOAP_ENC_OBJECT, "SOAPStruct", "http://soapinterop.org/xsd");

$client->echoStruct(new SoapParam($soapstruct, "inputStruct"));

?>

您是在说我将必须创建一个订户PHP类,分配所有变量$this-> FirstName = $first_name,等等…,然后将其放入编码为SOAP_ENC_OBJECT的SoapVar中?如何更好地表示用户结构?

解决方法:

有两种可能的Params订阅服务器和可覆盖的订阅服务器

string

string

string

string

boolean

因此,您需要使用SoapVar来表示次子结构来进行一些更复杂的构造.

我认为应该看起来像这样,尽管您可能想对照Soap:Body产生的XSD进行检查…

$subscriber = new StdClass();

$subscriber->ID = 'myid';

$subscriber->FirstName = 'First';

$subscriber->LastName = 'Last';

$subscriber = new SoapParam(new SoapVar($subscriber, SOAP_ENC_OBJECT, $type, $xsd), 'subscriber');

$type应该是api在XSD / WSDL定义中的类型,而$xsd是XSD的URI.

我认为应该这样做,但Ive仅将本机PHP库用于eBay一次(这是一场噩梦,哈哈),并且将近2年前,所以有点生锈.

标签:request,php,soap

来源: https://codeday.me/bug/20191210/2101451.html

版权声明:该文观点仅代表作者本人。处理文章:请发送邮件至 三1五14八八95#扣扣.com 举报,一经查实,本站将立刻删除。