Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/267.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/xml/13.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php Soap请求-不支持的媒体类型_Php_Xml_Soap - Fatal编程技术网

Php Soap请求-不支持的媒体类型

Php Soap请求-不支持的媒体类型,php,xml,soap,Php,Xml,Soap,我试图在PHP中使用SOAPClient从函数中获取一些值。我已经创建了代码,但得到的错误是不支持的媒体类型 我尝试研究这个问题,发现标题中的SOAP版本或内容类型可能是问题所在。。我想知道如何使用下面的代码在标题中设置SOAP版本和内容类型- 希望有人能帮忙。 谢谢 C 添加- SoapClient,arraysoap_version=>SOAP_1_2,trace=>true,异常=>1 为了确保请求使用1.2版SOAP。我回答晚了,但下面介绍如何使用此服务。这是一项从希腊税务局返回企业信息

我试图在PHP中使用SOAPClient从函数中获取一些值。我已经创建了代码,但得到的错误是不支持的媒体类型

我尝试研究这个问题,发现标题中的SOAP版本或内容类型可能是问题所在。。我想知道如何使用下面的代码在标题中设置SOAP版本和内容类型-

希望有人能帮忙。 谢谢 C

添加- SoapClient,arraysoap_version=>SOAP_1_2,trace=>true,异常=>1


为了确保请求使用1.2版SOAP。

我回答晚了,但下面介绍如何使用此服务。这是一项从希腊税务局返回企业信息的服务$AFMcalledby是调用方的增值税号码,$afmcalledf表示感兴趣的增值税号码,以及通过注册服务获得的用户名/密码

function checkVATGR($username,$password,$AFMcalledby="",$AFMcalledfor)
{
    $client = new SoapClient( "https://www1.gsis.gr/wsaade/RgWsPublic2/RgWsPublic2?WSDL",array('trace' => true, 'soap_version'=>SOAP_1_2) );


    $authHeader = new stdClass();
    $authHeader->UsernameToken=new stdClass();
    $authHeader->UsernameToken->Username = "$username";
    $authHeader->UsernameToken->Password = "$password";
    $Headers[] = new SoapHeader('http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd', 'Security', $authHeader,TRUE);
    $client->__setSoapHeaders($Headers);

    $result = $client->rgWsPublic2AfmMethod(
        array("INPUT_REC" => array(
            'afm_called_by'=>"$AFMcalledby",
            'afm_called_for'=>"$AFMcalledfor"
            ))
        );

    return $result;
}

您是否有任何[error_rec]=>stdClass对象[error_code]=>GEN_OTHER_EXCEPTION[error_descr]=>∑βαρπρρβλημαστηβσηδεδμέων这很奇怪,因为我的邮差电话工作正常,但您的代码返回了这个结果。
function checkVATGR($username,$password,$AFMcalledby="",$AFMcalledfor)
{
    $client = new SoapClient( "https://www1.gsis.gr/wsaade/RgWsPublic2/RgWsPublic2?WSDL",array('trace' => true, 'soap_version'=>SOAP_1_2) );


    $authHeader = new stdClass();
    $authHeader->UsernameToken=new stdClass();
    $authHeader->UsernameToken->Username = "$username";
    $authHeader->UsernameToken->Password = "$password";
    $Headers[] = new SoapHeader('http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd', 'Security', $authHeader,TRUE);
    $client->__setSoapHeaders($Headers);

    $result = $client->rgWsPublic2AfmMethod(
        array("INPUT_REC" => array(
            'afm_called_by'=>"$AFMcalledby",
            'afm_called_for'=>"$AFMcalledfor"
            ))
        );

    return $result;
}