• 05-05-2025, 18:31:52
    #1
    php ile soap kullanarak aşağıdaki gibi istek yolluyorum ama "Kullanıcı adı veya şifre hatalı." dönüyor. burada hata var mı? destek ekibine yazdım sistemde şuan sorun yok dediler.

    $this->client = new Client($config['surat']);
    $result = $this->client->getShipments($startDate, $endDate);
    
    public function getShipments($startDate, $endDate)
    {
    $params = [
    'GonderenCariKodu' => 'carikodu',
    'WebPassword' => 'şifre',
    'BasTar' => $startDate,
    'BitTar' => $endDate,
    'IsWebSiparisKoduOlsun' => false
    ];
    
    return $this->requestManager->request('CariKoduveSifre', $params);
    }
    Request manager classı;
    public function __construct($wsdl)
    {
    $this->client = new SoapClient($wsdl, ['trace' => 1, 'cache_wsdl' => WSDL_CACHE_NONE]);
    }
    
    public function request($method, $params)
    {
    return $this->client->$method($params);
    }
  • 05-05-2025, 18:49:47
    #2
    Hata olsa bağlanmaz bağlanmayacağı için de yanıt dönmez doğal olarak kod çalışmaz ama siz hata alıyorum diyorsunuz o zaman hata kodu neyse api tarafında dönen sorun o'dur yani kısacası kullanıcı adı ve şifreye daha dikkatli bakın bazen "boşluk" karakteri araya kaynayabiliyor sorun olabiliyor
  • 05-05-2025, 18:52:57
    #3
    phpwebdeveloper adlı üyeden alıntı: mesajı görüntüle
    Hata olsa bağlanmaz bağlanmayacağı için de yanıt dönmez doğal olarak kod çalışmaz ama siz hata alıyorum diyorsunuz o zaman hata kodu neyse api tarafında dönen sorun o'dur yani kısacası kullanıcı adı ve şifreye daha dikkatli bakın bazen "boşluk" karakteri araya kaynayabiliyor sorun olabiliyor
    bilgiler doğru tekrar tekrar kontrol ettim, belki php ile sürat kargo soap kullanan vardır diye açtım aslında konuyu. postman ile de istek gönderdim aşağıdaki şekilde ama hala "Kullanıcı adı veya şifre hatalı." dönüyor.
    sürat kargo web sitesinde bu bilgilerle giriş yapabiliyorumda

    curl --location 'http://webservices.suratkargo.com.tr/services.asmx' \
    --header 'Content-Type: text/xml; charset=utf-8' \
    --header 'SOAPAction: "http://tempuri.org/CariKoduveSifre"' \
    --data '<?xml version="1.0" encoding="utf-8"?>
    <soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
                   xmlns:xsd="http://www.w3.org/2001/XMLSchema"
                   xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
      <soap:Body>
        <CariKoduveSifre xmlns="http://tempuri.org/">
          <GonderenCariKodu>Mailde yazdıkları Cari kodu (Kullanıcı Adı) </GonderenCariKodu>
          <WebPassword>Mailde Yazdıkları şifre</WebPassword>
          <BasTar>2025-05-01</BasTar>
          <BitTar>2025-05-05</BitTar>
          <IsWebSiparisKoduOlsun>false</IsWebSiparisKoduOlsun>
        </CariKoduveSifre>
      </soap:Body>
    </soap:Envelope>
    '
  • 05-05-2025, 22:19:42
    #4
    Aramızdan Ayrılanlar - Vefat Edenler
    <?php

    namespace AppServices;

    use SoapClient;
    use SoapFault;
    use Exception;
    use PsrLogLoggerInterface;

    class ShipmentService
    {
    /**
    * @var SoapClient
    */
    protected $client;

    /**
    * @var array
    */
    protected $config;

    /**
    * @var LoggerInterface
    */
    protected $logger;

    /**
    * ShipmentService constructor.
    *
    * @param array $config
    * @param LoggerInterface $logger
    */
    public function __construct(array $config, LoggerInterface $logger)
    {
    $this->config = $config;
    $this->logger = $logger;

    try {
    $this->initializeClient();
    } catch (Exception $e) {
    $this->logger->error('SOAP client initialization failed', [
    'error' => $e->getMessage(),
    'wsdl' => $config['surat']['wsdl'] ?? 'undefined'
    ]);
    throw $e;
    }
    }

    /**
    * Initialize the SOAP client
    */
    protected function initializeClient()
    {
    $options = [
    'trace' => 1,
    'cache_wsdl' => WSDL_CACHE_NONE,
    'exceptions' => true,
    'connection_timeout' => 30
    ];

    if (!isset($this->config['surat']['wsdl'])) {
    throw new Exception('WSDL URL is not defined in configuration');
    }

    $this->client = new SoapClient($this->config['surat']['wsdl'], $options);
    }

    /**
    * Get shipments between given dates
    *
    * @param string $startDate Start date in Y-m-d format
    * @param string $endDate End date in Y-m-d format
    * @param bool $useWebOrderCode Whether to use web order code
    * @return array
    * @throws Exception
    */
    public function getShipments($startDate, $endDate, $useWebOrderCode = false)
    {
    if (!$this->validateDateFormat($startDate) || !$this->validateDateFormat($endDate)) {
    throw new Exception('Invalid date format. Use Y-m-d format.');
    }

    $params = [
    'GonderenCariKodu' => $this->config['surat']['cari_kodu'] ?? '',
    'WebPassword' => $this->config['surat']['password'] ?? '',
    'BasTar' => $startDate,
    'BitTar' => $endDate,
    'IsWebSiparisKoduOlsun' => $useWebOrderCode
    ];

    try {
    $result = $this->request('CariKoduveSifre', $params);
    $this->logger->info('Shipments retrieved successfully', [
    'start_date' => $startDate,
    'end_date' => $endDate
    ]);
    return $result;
    } catch (Exception $e) {
    $this->logger->error('Failed to retrieve shipments', [
    'error' => $e->getMessage(),
    'start_date' => $startDate,
    'end_date' => $endDate
    ]);
    throw $e;
    }
    }

    /**
    * Make a SOAP request
    *
    * @param string $method
    * @param array $params
    * @return mixed
    * @throws SoapFault
    */
    protected function request($method, $params)
    {
    try {
    $response = $this->client->$method($params);
    return $this->processResponse($response);
    } catch (SoapFault $fault) {
    $this->logger->error('SOAP request failed', [
    'method' => $method,
    'fault_code' => $fault->faultcode,
    'fault_string' => $fault->faultstring
    ]);
    throw $fault;
    }
    }

    /**
    * Process and normalize the SOAP response
    *
    * @param mixed $response
    * @return array
    */
    protected function processResponse($response)
    {
    // Burada response'u işleyebilir, dönüştürebilir veya doğrulayabilirsiniz
    // Örneğin XML'i array'e çevirebilir veya belirli alanları kontrol edebilirsiniz

    return $response;
    }

    /**
    * Validate date format
    *
    * @param string $date
    * @return bool
    */
    protected function validateDateFormat($date)
    {
    $d = DateTime::createFromFormat('Y-m-d', $date);
    return $d && $d->format('Y-m-d') === $date;
    }

    /**
    * Get last request XML
    *
    * @return string
    */
    public function getLastRequestXml()
    {
    return $this->client->__getLastRequest();
    }

    /**

    * Get last response XML
    *
    * @return string
    */
    public function getLastResponseXml()
    {
    return $this->client->__getLastResponse();
    }
    }

    GitHubda buldum