I'm learning php trying to get data from a wsdl service. The service method I'm requesting data from requires two parameters, one of which requires an arrayOfstring type. So somehow I'm needing to pass a value like this ACCT_ID[0] to the soapClient method. Here are the parameters the method requires:
我正在学习php试图从wsdl服务获取数据。我正在请求数据的服务方法需要两个参数,其中一个参数需要arrayOfstring类型。所以不知何故,我需要将这个ACCT_ID [0]的值传递给soapClient方法。以下是该方法所需的参数:
<s:sequence>
<s:element minOccurs="0" maxOccurs="1" name="ACCT_ID" type="tns:ArrayOfString"/>
<s:element minOccurs="1" maxOccurs="1" name="UserNumber" type="s:long"/>
</s:sequence>
The ACCT_ID requires an arrayOfString type passed to it through the PHP soapclient. I'm stuck on how this is done. This is where I'm at so far:
ACCT_ID需要通过PHP soapclient传递给它的arrayOfString类型。我一直坚持如何做到这一点。这是我到目前为止的地方:
$client = new soapClient('http://webservice/accountdata.asmx?wsdl', array('trace' => 1));
//method paramaters
$user_num = 20;
$acct_id = "98765431654654654656, 44986532156469898442";
$ACCT_ID = explode(" ", $acct_id);
$params = array("ACCT_ID" => $ACCT_ID[0], "UserNumber" => $user_num);
$response = $client->Account_Data($params);
so I've got the soapClient object with a method Account_Data and I'm passing $params to it. I've tested it with these parameters using the Storm tool and I did get the proper xml response. And I can see in the browser source that UserNumber is being sent to the webservice, but not ACCT_ID[0]. I've tried all sorts of things, but I'm not sure where to go from here. How can I pass an arrayOfString type parameter to the webservice through php? Thank you!
所以我有一个方法Account_Data的soapClient对象,我将$ params传递给它。我使用Storm工具测试了这些参数,我确实获得了正确的xml响应。我可以在浏览器源中看到UserNumber正在发送到Web服务,但不是ACCT_ID [0]。我尝试了各种各样的东西,但我不知道从哪里开始。如何通过php将arrayOfString类型参数传递给webservice?谢谢!
1 个解决方案
#1
-1
Convert the parameter into a json string.
将参数转换为json字符串。
$acct_id = array(806796224000,000000000000);
$ACCT_ID = json_encode($acct_id);
#1
-1
Convert the parameter into a json string.
将参数转换为json字符串。
$acct_id = array(806796224000,000000000000);
$ACCT_ID = json_encode($acct_id);