مهدی سمیعیان
4 سال پیش توسط مهدی سمیعیان مطرح شد
2 پاسخ

وب سرویس پنل پست

توی استفاده از یک متد وب سرویس پنل پست به مشکل خوردم
متد AddParcel
توی راهنما گفته که باید لیستی از کد محصولات طبق کد زیر ارسال بشه.

var tempProduct = new ServiceReference1.TempProducts[1]; tempProduct[0] = new ServiceReference1.TempProducts(); tempProduct[0].Id = 20317;
tempProduct[0].Count = 1;
tempProduct[0].Discount = 0;
tempProduct[1] = new TempProducts();
tempProduct[1].Id = 3646;
tempProduct[1].Count = 1;
tempProduct[1].Discount = 0;

نمونه بالا فکر کنم c# باشه. من توی php هم ارایه بهش پاس دادم. هم کلاس. هم ارایه ای از کلاس ها ولی هیچکدوم نتیجه نداد.
کسی میدونه خروجی کد بالا چه ساختاری داره که من طبق همون ارایه یا کلاسم رو تنظیم کنم؟
لینک فایل pdf راهنما استفاده از وب سرویس پنل پست:
https://ebazar.post.ir/Contents/files/EBazar-WebService-Guide.pdf
لینک نمونه کد asp.net و php
https://ebazar.post.ir/Contents/files/ebazar-websvc-sample.rar


ثبت پرسش جدید
سیدعلی موسوی
تخصص : سی شارپ و پی اچ پی
@juza66 4 سال پیش آپدیت شد
0

طبق مستندات فایل PHP شما میتونید یک ارایه رو با SoapClient به اون مسیر ارسال کنید.

<?php

    $username = 'demo';
    $password = 'demo';

    //Create a web service proxy using SoapClient
    $client = new SoapClient('http://svc.ebazaar-post.ir/EshopService.svc?WSDL');
    $client->soap_defencoding = 'UTF-8';
    $client->decode_utf8 = false;

    //Get Price
    $price=$client->GetDeliveryPrice(['username' => $username,'password'=>$password,'cityCode'=>31,'price'=>500000,'weight'=>3500,'serviceType'=>1,'payType'=>1]);

    //Get list of states
    $states=$client->GetStates(['username' => $username,'password'=>$password]);

    //Get list of cities
    $cities=$client->GetCities(['username' => $username,'password'=>$password,'stateId'=>1]);

    $bills=$client->Billing(['username' => $username,'password'=>$password]);

    $products=array();

    //add 3 stuffs (product)
    for($i=0;$i<3;$i++)
    {
        $result = $client -> AddStuff ([
            'username' => $username,
            'password' => $password,
            'name' => 'PRODUCT_NAME',
            'price' => 1000, // product price (in IRR Rials)
            'weight' => 20,  // product weight (in gram)
            'count' => 10, // stock count
            'description' => 'تست', // product description
            'percentDiscount' => 0, // product discount
        ]);

        $stuff_id=(int)$result->AddStuffResult;

        $products[]=
        [
            'Id' => $stuff_id, // Product id in ebazaar
            'Count' => 1, // order line quantity
            'DisCount' => 0 // No Discount
        ];
    }

    //Add parcel and get 20-digit tracking code
    $add_parcel_result = $client -> AddParcel ([
        'username' => $username,
        'password' => $password,
        'productsId' => $products,
        'cityCode' => 1,
        'serviceType' => 2, // pishtaz
        'payType' => 88, // free shipping
        'registerFirstName' => 'تست', // first name
        'registerLastName' => 'ام پوز', // last name
        'registerAddress' => 'نشانی', //postal address
        'registerPhoneNumber' => 'تلفن', // fixed line telephone number
        'registerMobile' => 'موبایل', // cell number
        'registerPostalCode' => '1598994733' // 10-digit postcode
    ]);

    echo '<h2>Get Price</h2><hr /><p>get delivery price.</p><div class="container">';
    highlight_string("<?php\n\$data =\n" . var_export($price, true) . ";\n?>");
    echo '</div>';
    echo '<h2>States</h2><hr /><p>Get list of all states.</p><div class="container">';
    highlight_string("<?php\n\$data =\n" . var_export($states, true) . ";\n?>");
    echo '</div>';
    echo '<h2>Cities</h2><hr /><p>Get list of all cities by stateId</p><div class="container">';
    highlight_string("<?php\n\$data =\n" . var_export($cities, true) . ";\n?>");
    echo '</div>';
    echo '<h2>Add Parcel Results</h2><p>Adding a parcel and get 20-digit post tracking code</p><hr /><div class="container">';
    highlight_string("<?php\n\$data =\n" . var_export($add_parcel_result, true) . ";\n?>");
    echo '</div>';
    echo '<h2>Billing Result</h2><p>Get list of bills</p><hr /><div class="container">';
    highlight_string("<?php\n\$data =\n" . var_export($bills, true) . ";\n?>");
    echo '</div>';
    $parcel_code=$add_parcel_result->AddParcelResult->ParcelCode;

    echo '<p>Parcel Code=' .$parcel_code.'</p>';
?>

مهدی سمیعیان
تخصص : برنامه نویس وب/اندروید
@mahdidev 4 سال پیش مطرح شد
0

@juza66
ارایه رو همونطوری فرستادم و نتیجه نگرفتم. به صورت آبجکت و لیست آبجکت هم فرستادم بازم مشکل داشته


برای ارسال پاسخ لازم است وارد شده یا ثبت‌نام کنید

ورود یا ثبت‌نام