编辑:我设法通过要求服务器开发人员将字符串拆分为他身边的数组来解决这个问题。现在可以了。
无论如何,我从来不知道如何正确地将数组传递给 .NET 肥皂服务器。
我在 PHP 中有一个不工作的 SOAP 客户端。服务器开发人员为我处理了一个有效的 .NET 示例。我都贴在这里。我错过了什么吗?
问候
PHP代码
$res = new cResult;
//$oRequest = new InsertVenta; (throws the same error wether this is specified or not)
$pcAccesorios = new cACC_VENTA;
$oUSER = new cUSER;
$oUSER->LOGIN = "hidden";
$oUSER->PASS = "hidden";
//$oUSER->ERROR = 0;
$oAVISO = new cVENTA;
$oAVISO->NOMBRE = str_pad($nombre, 150);
$oAVISO->DIRECCION = str_pad($direccion, 250);
$oAVISO->CP = str_pad($codpostal, 5);
$oAVISO->POBLACION = str_pad($poblacion, 150);
$oAVISO->PROVINCIA = str_pad($provincia, 75);
$oAVISO->PERS_CONTACTO = str_pad($pers_contacto, 150);
$oAVISO->TFNS_CONTACTO = str_pad($telefono, 50);
$oAVISO->EMAIL = str_pad($email, 75);
$oAVISO->NIF = str_pad($nifcif, 10);
$oAVISO->ERROR = 0;
//$oAVISO->HasError = 0;
//$oAVISO->$ID_ORDEN = 0;
$oRequest->oUSER = $oUSER;
$oRequest->oAVISO = $oAVISO;
$maxindex = count($listacompra);
for ( $i = 0 ; $i < $maxindex; $i++) {
$array_de_2 = explode(" ", $listacompra[$i]);
$pcAccesorios->REFERENCIA = $array_de_2[1];
$pcAccesorios->UNIDADES = $array_de_2[0];
$oRequest->oACC[$i] = $pcAccesorios;
}
//$oRequest->oACC = $oACC;
//var_dump($oRequest);
try {
$client = new SoapClient($wdsladdress, array("trace" => 1,"exceptions"=>0));
//print $client->__getTypes();
//var_dump($client->__getFunctions());
//print "conectado ";
} catch (Exception $e) {
echo '', $e->getMessage(), "\n";
die();
}
try {
//$res=$client->INSERT_VENTA($oUSER, $oAVISO, $oACC);
$res=$client->INSERT_VENTA($oRequest);
//$client->__getLastRequest();
//$res->INSERT_VENTAResult;
$ID_ORDEN=(string)$res->INSERT_VENTAResult->ID_ORDEN;
var_dump($ID_ORDEN);
print var_dump($res);
} catch (Exception $e) {
echo '', $e->getMessage(), "\n";
die();
}
.NET 代码
Dim oAVISO As New WS_TSG.cVENTA
oAVISO.CP = "24400"
oAVISO.DIRECCION = "Mi direccion "
oAVISO.EMAIL = "email@servidor.com "
'oAVISO.ID_ORDEN =
oAVISO.NIF = "A12345678 "
oAVISO.NOMBRE = "Mi nombre "
oAVISO.PERS_CONTACTO = "Anonimo Nadie "
oAVISO.POBLACION = "Vega de la esquina "
oAVISO.PROVINCIA = "Leon "
oAVISO.TFNS_CONTACTO = "987343434 "
Dim oACC As New WS_TSG.ArrayOfCACC_VENTA
Dim oACC_VENTA As New WS_TSG.cACC_VENTA
oACC_VENTA.REFERENCIA = "KITHDTV72"
oACC_VENTA.UNIDADES = "1"
oACC.Add(oACC_VENTA)
oACC_VENTA.REFERENCIA = "USBTV82"
oACC_VENTA.UNIDADES = "2"
oACC.Add(oACC_VENTA)
oACC_VENTA.REFERENCIA = "ACDCTV425"
oACC_VENTA.UNIDADES = "1"
oACC.Add(oACC_VENTA)
oAVISO = WS.INSERT_VENTA(oUSER, oAVISO, oACC)
错误是:
服务器无法读取请求。---> XML 文档中存在错误 (2, 280)。---> 输入字符串的格式不正确。
有什么帮助吗?谢谢!