肥皂的新蜂,我想请求肥皂api,我是否需要使用php创建肥皂客户端

问题描述 投票:-2回答:1

请帮助我使用PHP创建肥皂请求。我必须获取库存和产品详细信息。用于添加API。

php soap soap-client ksoap2 android-ksoap2
1个回答
0
投票

无需创建肥皂客户端,您可以轻松创建xml表单并发送请求

function SendRequest($url,$data){
    global $curl; //initiate curl
    $curl->setHeader('Content-Type','text/xml');
    $xml = new DOMDocument( '1.0', 'UTF-8');
    $ocs_request=$xml->createElement("ocsRequest");
    foreach($data As $key=>$value){
        ${$key} = $xml->createElement($key,$value);
        $ocs_request->appendChild(${$key});
    }
    $xml->appendChild($ocs_request);
    $xml = $xml->saveXML();
    $post = $curl->post($url,$xml); //you can change post, get depending on your request type
    return $post;
}
© www.soinside.com 2019 - 2024. All rights reserved.