XML
$xml = "<?xml version='1.0' encoding='utf-8'?>
<soap12:Envelope xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance' xmlns:xsd='http://www.w3.org/2001/XMLSchema' xmlns:soap12='http://www.w3.org/2003/05/soap-envelope'>
<soap12:Body>
<GetProviderTrades xmlns='ZuluTrade.WebServices'>
<providerId>128391</providerId>
<currencyIds>
<string>EURUSD</string>
<string>USDCAD</string>
</currencyIds>
<fromDateStr>1986-08-27T09:00:00</fromDateStr>
<toDateStr>2014-01-12T09:00:00</toDateStr>
<validTrades>true</validTrades>
<lotSize>Standard</lotSize>
<start>0</start>
<length>20</length>
<sortBy>dc</sortBy>
<sortAscending>false</sortAscending>
</GetProviderTrades>
</soap12:Body>
</soap12:Envelope>";
请求函数
function http_post ($url, $xml)
{
date_default_timezone_set('America/New_York');
$post_string = $xml;
$soap_do = curl_init();
curl_setopt($soap_do, CURLOPT_URL, $url );
curl_setopt($soap_do, CURLOPT_CONNECTTIMEOUT, 10);
curl_setopt($soap_do, CURLOPT_TIMEOUT, 10);
curl_setopt($soap_do, CURLOPT_RETURNTRANSFER, true );
curl_setopt($soap_do, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($soap_do, CURLOPT_SSL_VERIFYHOST, false);
curl_setopt($soap_do, CURLOPT_POST, true );
curl_setopt($soap_do, CURLOPT_POSTFIELDS, $post_string);
curl_setopt($soap_do, CURLOPT_HTTPHEADER, array('Content-Type: text/xml; charset=utf-8', 'Content-Length: '.strlen($post_string) ));
//curl_setopt($soap_do, CURLOPT_USERPWD, $user . ":" . $password);
$result = curl_exec($soap_do);
$err = curl_error($soap_do);
return $result;
}
致电
$postRequest = http_post('http://www.zulutrade.com/WebServices/Performance.asmx?op=GetProviderTrades',$xml);
完整回复
soap:ServerServer was unable to process request. ---> There was an error generating the XML document. ---> <>f__AnonymousType55`2[System.Int32,Z.T[]] cannot be serialized because it does not have a parameterless constructor.
WSDL http://www.zulutrade.com/WebServices/Performance.asmx?WSDL
没有发现我正在做什么,有什么想法?
答案 0 :(得分:0)
<currencyIds>
<string>EURUSD</string>
<string>USDCAD</string>
</currencyIds>
根据你的wsdl,它是ArrayOfInt而不是ArrayOfString。
<s:element name="GetProviderTrades">
<s:complexType>
<s:sequence>
<s:element minOccurs="1" maxOccurs="1" name="providerId" type="s:int" />
<s:element minOccurs="0" maxOccurs="1" name="currencyIds" type="tns:ArrayOfInt" />
<s:element minOccurs="0" maxOccurs="1" name="fromDateStr" type="s:string" />
<s:element minOccurs="0" maxOccurs="1" name="toDateStr" type="s:string" />
<s:element minOccurs="1" maxOccurs="1" name="validTrades" type="s:boolean" />
<s:element minOccurs="1" maxOccurs="1" name="lotSize" type="tns:LotSize" />
<s:element minOccurs="1" maxOccurs="1" name="start" type="s:int" />
<s:element minOccurs="1" maxOccurs="1" name="length" type="s:int" />
<s:element minOccurs="0" maxOccurs="1" name="sortBy" type="s:string" />
<s:element minOccurs="1" maxOccurs="1" name="sortAscending" type="s:boolean" />
</s:sequence>
</s:complexType>
</s:element>
而ArrayOfInt是,
<s:complexType name="ArrayOfInt">
<s:sequence>
<s:element minOccurs="0" maxOccurs="unbounded" name="int" type="s:int" />
</s:sequence>
</s:complexType>
所以你的请求xml应该是这样的,
<currencyIds>
<int>11</int>
<int>22</int>
</currencyIds>