来自php的身份验证的SOAP webservice连接

时间:2015-12-10 19:02:00

标签: c# php web-services authentication soap

我有这个wsdl: https://www.dropbox.com/s/juprwr1ywqtbry5/wsdl.xml?dl=0

我试图这样做:

$ws_params = array('usuario' => "admin", 'clave' => "123456");
    $client = new SoapClient("http://ws_min.mindtec.ar/ws_cnv/wscnv.asmx?wsdl");
    $header    = new SoapHeader("http://tempuri.org/", 'credencialcnv', $ws_params);
    $client->__setSoapHeaders($header);
    $res = $client->obtenerCNV_OPS(array("sFecha"=>"20151110"));
    var_dump($res);

我明白了:

 object(stdClass)#3 (1) {
  ["obtenerCNV_OPSResult"]=>
  object(stdClass)#4 (0) {
  }
}

我得到一个空对象,因为Web服务不采用身份验证设置。另一方面,我可以使用以下内容轻松地从Visual Basic或.net连接:

Dim ws As New wscnv.wscnv
Dim oCredencial As New wscnv.CredencialCNV
oCredencial.usuario = "usuario123"
oCredencial.clave = "clave123"
ws.CredencialCNVValue = oCredencial
Dim listCNV As Array
listCNV = ws.obtenerCNV(txtFecha.Text)

或者来自C#:

wscnv.wscnv ws = new wscnv.wscnv();
wscnv.CredencialCNV oCredencial = new wscnv.CredencialCNV();
oCredencial.usuario = "usuario123";
oCredencial.clave = "clave123";
ws.CredencialCNVValue = oCredencial;
Array listCNV = null;
listCNV = ws.obtenerCNV(txtFecha.Text);

我做错了什么?

0 个答案:

没有答案