简体   繁体   中英

PHP XML Soap request

How I can do below soap request in php,

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:v="http://incometaxindiaefiling.gov.in/ditws/TaxCredMismatch/v_1_0">
    <soapenv:Header/>
        <soapenv:Body>
        <v:getTaxCredMismatchRequest>
        <LoginInfo>
            <userName>XXXXXXXXXX</userName>
            <password>XXXXXXXXXX</password>
        </LoginInfo>
        <UserInput>
            <panNo>XXXXXXXXXX</panNo>
            <asseessmentyear>XXXX-XX</asseessmentyear>
        </UserInput>
    </v:getTaxCredMismatchRequest>
</soapenv:Body>
</soapenv:Envelope>

I tried below code,

<?php
    $url = "https://incometaxindiaefiling.gov.in/e-FilingWS/ditws/getTaxCredMismatchRequest.wsdl";
    try {        
        $options = array( 
                'soap_version'=>SOAP_1_1, 
                'exceptions'=>true, 
                'trace'=>1, 
                'cache_wsdl'=>WSDL_CACHE_NONE 
            );         
        $client = new SoapClient($url,$options);
        $requestParams = array(
            'userName' => 'AJAPA5855E',
            'password' => 'pass123',
            'panNo' =>  'AJAPA5855E',
            'asseessmentyear' => '2014-15'
        );        
        $response = $client->__soapCall("getTaxCredMisMatch", array($requestParams));
        var_dump($response);
    } catch (Exception $e) { 
        echo $e->getMessage(); 
    }
?>

but getting the response as

SOAP-ERROR: Encoding: object has no 'LoginInfo' property

I know, I'm sending the parameter in correct way, may I know how to correct it.

I never used that soap client, but I would expect this:

<?php
    $url = "https://incometaxindiaefiling.gov.in/e-FilingWS/ditws/getTaxCredMismatchRequest.wsdl";
    try {        
        $options = array( 
                'soap_version'=>SOAP_1_1, 
                'exceptions'=>true, 
                'trace'=>1, 
                'cache_wsdl'=>WSDL_CACHE_NONE 
            );         
        $client = new SoapClient($url,$options);
        $requestParams = array(
            'LoginInfo' => array (
                'userName' => 'AJAPA5855E',
                'password' => 'pass123',
            ),
            'UserInput' => array (
                'panNo' =>  'AJAPA5855E',
                'asseessmentyear' => '2014-15'
            )
        );        
        $response = $client->__soapCall("getTaxCredMisMatch", array($requestParams));
        var_dump($response);
    } catch (Exception $e) { 
        echo $e->getMessage(); 
    }
?>

However as said above, this is just a wild guess. It certainly would make sense to take a look at the documentation of that extension: http://php.net/manual/en/class.soapclient.php . Such things should be explained in there...

Using the WSDL from https://incometaxindiaefiling.gov.in/e-FilingWS/ditws/getTaxCredMismatchRequest.wsdl , you could generate the corresponding package from wsdltophp.com in order to be sure on how to structure your request in PHP as every element will be a PHP object with setters/getters. It uses the native PHP SoapClient class so you'll understand easily and quickly who to send these requests if you're familiar with PHP

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM