Page 1 of 1

PHP - NUSOAP - .NET SERVER - SCHEMA

Posted: Fri Aug 13, 2004 6:51 pm
by hserna
feyd | Please use

Code: Select all

and

Code: Select all

tags where approriate when posting code. Read:  [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url][/color]


Hi all of you !!!


I had to program a SOAP Client to connect to a .NET Server.
But I had to create a SOAP message which have to include
a previously given schema (included in this post).
But I don't know how to include the schema as part of the Soap message.

Can you help me?


This is my code so far (this code works with other functions in this server):

Code: Select all

<?php
require_once('nusoap.php');


$soapclient->debug_flag = 1;

$params = array(
'usuario' => "test",
'password' => "test1"
);

$namespace="http://tempuri.org/";
$soapaction="http://tempuri.org/CargaRemision";

$soapclient = new soapclient("http://www.soriana.com/sprov/ColaboracionElectronica/Pruebas/ServiciosWeb/RemisionElectronica/svcCargaRemision.asmx");


if($err = $soapclient->getError())
{
// handle error however
print_r ($err);
}
else
{
$result = $soapclient->call("CargaRemision",$params,$namespace,$soapaction,false,null,'rpc','literal');
if($err2 = $soapclient->getError())
{
print_r ($err2);
echo '<h2>Request</h2>';
echo '<pre>' . htmlspecialchars($soapclient->request, ENT_QUOTES) . '</pre>';
echo '<h2>Response</h2>';
echo '<pre>' . htmlspecialchars($soapclient->response, ENT_QUOTES) . '</pre>';
echo '<h2>Debug</h2>';
echo '<pre>' . htmlspecialchars($soapclient->debug_str, ENT_QUOTES) . '</pre>';
}
else
{
// do something w/ return val
print_r ($result);
}
}

?>





This is the SOAP message that I had to create:

Code: Select all

POST /sprov/ColaboracionElectronica/Pruebas/ServiciosWeb/RemisionElectronica/svcValidaRemision.asmx HTTP/1.1
Host: www.soriana.com
Content-Type: text/xml; charset=utf-8
Content-Length: length
SOAPAction: "http://tempuri.org/ValidaRemision"

&lt;?xml version="1.0" encoding="utf-8"?&gt;
&lt;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/"&gt;
&lt;soap:Body&gt;
&lt;ValidaRemision xmlns="http://tempuri.org/"&gt;
&lt;dsCargaRemision&gt;
&lt;xsd:schema&gt;schema&lt;/xsd:schema&gt;xml&lt;/dsCargaRemision&gt;
&lt;Usuario&gt;string&lt;/Usuario&gt;
&lt;Contrasena&gt;string&lt;/Contrasena&gt;
&lt;/ValidaRemision&gt;
&lt;/soap:Body&gt;
&lt;/soap:Envelope&gt;

And this is the SCHEMA:

Code: Select all

&lt;?xml version="1.0" encoding="utf-8" ?&gt;
&lt;xs:schema id="DSCargaRemisionProv" targetNamespace="http://tempuri.org/DSCargaRemisionProv.xsd" elementFormDefault="qualified" attributeFormDefault="qualified" xmlns="http://tempuri.org/DSCargaRemisionProv.xsd" xmlns:mstns="http://tempuri.org/DSCargaRemisionProv.xsd" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata"&gt;
&lt;xs:element name="DSCargaRemisionProv" msdata:IsDataSet="true"&gt;
&lt;xs:complexType&gt;
&lt;xs:choice maxOccurs="unbounded"&gt;
&lt;xs:element name="Remision"&gt;
&lt;xs:complexType&gt;
&lt;xs:sequence&gt;
&lt;xs:element name="Proveedor" type="xs:int" /&gt;
&lt;xs:element name="Remision" type="xs:string" /&gt;
&lt;xs:element name="Consecutivo" type="xs:short" /&gt;
&lt;xs:element name="FechaRemision" type="xs:dateTime" /&gt;
&lt;xs:element name="Tienda" type="xs:short" /&gt;
&lt;xs:element name="TipoMoneda" type="xs:short" /&gt;
&lt;xs:element name="TipoBulto" type="xs:short" /&gt;
&lt;xs:element name="EntregaMercancia" type="xs:short" /&gt;
&lt;xs:element name="CumpleReqFiscales" type="xs:boolean" /&gt;
&lt;xs:element name="CantidadBultos" type="xs:decimal" /&gt;
&lt;xs:element name="Subtotal" type="xs:decimal" /&gt;
&lt;xs:element name="Descuentos" type="xs:decimal" /&gt;
&lt;xs:element name="IEPS" type="xs:decimal" /&gt;
&lt;xs:element name="IVA" type="xs:decimal" /&gt;
&lt;xs:element name="OtrosImpuestos" type="xs:decimal" /&gt;
&lt;xs:element name="Total" type="xs:decimal" /&gt;
&lt;xs:element name="CantidadPedidos" type="xs:int" /&gt;
&lt;xs:element name="FechaEntregaMercancia" type="xs:dateTime" nillable="true" /&gt;
&lt;/xs:sequence&gt;
&lt;/xs:complexType&gt;
&lt;/xs:element&gt;
&lt;xs:element name="Pedimento"&gt;
&lt;xs:complexType&gt;
&lt;xs:sequence&gt;
&lt;xs:element name="Proveedor" type="xs:int" /&gt;
&lt;xs:element name="Remision" type="xs:string" /&gt;
&lt;xs:element name="Pedimento" type="xs:int" /&gt;
&lt;xs:element name="Aduana" type="xs:short" /&gt;
&lt;xs:element name="AgenteAduanal" type="xs:short" /&gt;
&lt;xs:element name="TipoPedimento" type="xs:string" /&gt;
&lt;xs:element name="FechaPedimento" type="xs:dateTime" /&gt;
&lt;xs:element name="FechaReciboLaredo" type="xs:dateTime" /&gt;
&lt;xs:element name="FechaBillOfLading" type="xs:dateTime" /&gt;
&lt;/xs:sequence&gt;
&lt;/xs:complexType&gt;
&lt;/xs:element&gt;
&lt;xs:element name="Pedidos"&gt;
&lt;xs:complexType&gt;
&lt;xs:sequence&gt;
&lt;xs:element name="Proveedor" type="xs:int" /&gt;
&lt;xs:element name="Remision" type="xs:string" /&gt;
&lt;xs:element name="FolioPedido" type="xs:int" /&gt;
&lt;xs:element name="Tienda" type="xs:short" /&gt;
&lt;xs:element name="CantidadArticulos" type="xs:int" /&gt;
&lt;/xs:sequence&gt;
&lt;/xs:complexType&gt;
&lt;/xs:element&gt;
&lt;xs:element name="Articulos"&gt;
&lt;xs:complexType&gt;
&lt;xs:sequence&gt;
&lt;xs:element name="Proveedor" type="xs:int" /&gt;
&lt;xs:element name="Remision" type="xs:string" /&gt;
&lt;xs:element name="FolioPedido" type="xs:int" /&gt;
&lt;xs:element name="Tienda" type="xs:short" /&gt;
&lt;xs:element name="Codigo" type="xs:decimal" /&gt;
&lt;xs:element name="CantidadUnidadCompra" type="xs:decimal" /&gt;
&lt;xs:element name="CostoNetoUnidadCompra" type="xs:decimal" /&gt;
&lt;xs:element name="PorcentajeIEPS" type="xs:decimal" /&gt;
&lt;xs:element name="PorcentajeIVA" type="xs:decimal" /&gt;
&lt;/xs:sequence&gt;
&lt;/xs:complexType&gt;
&lt;/xs:element&gt;
&lt;/xs:choice&gt;
&lt;/xs:complexType&gt;
&lt;xs:key name="DSCargaRemisionProvKey1" msdata:PrimaryKey="true"&gt;
&lt;xs:selector xpath=".//Remision" /&gt;
&lt;xs:field xpath="mstns:Proveedor" /&gt;
&lt;xs:field xpath="Remision" /&gt;
&lt;/xs:key&gt;
&lt;xs:key name="DSCargaRemisionProvKey3" msdata:PrimaryKey="true"&gt;
&lt;xs:selector xpath=".//mstns:Pedimento" /&gt;
&lt;xs:field xpath="mstns:Proveedor" /&gt;
&lt;xs:field xpath="Remision" /&gt;
&lt;/xs:key&gt;
&lt;xs:key name="DSCargaRemisionProvKey4" msdata:PrimaryKey="true"&gt;
&lt;xs:selector xpath=".//mstns:Pedidos" /&gt;
&lt;xs:field xpath="mstns:Proveedor" /&gt;
&lt;xs:field xpath="Remision" /&gt;
&lt;xs:field xpath="mstns:FolioPedido" /&gt;
&lt;/xs:key&gt;
&lt;xs:key name="DSCargaRemisionProvKey5" msdata:PrimaryKey="true"&gt;
&lt;xs:selector xpath=".//Articulos" /&gt;
&lt;xs:field xpath="mstns:Proveedor" /&gt;
&lt;xs:field xpath="mstns:Remision" /&gt;
&lt;xs:field xpath="mstns:FolioPedido" /&gt;
&lt;xs:field xpath="mstns:Tienda" /&gt;
&lt;xs:field xpath="mstns:Codigo" /&gt;
&lt;/xs:key&gt;
&lt;xs:keyref name="RemisionPedimento" refer="DSCargaRemisionProvKey1"&gt;
&lt;xs:selector xpath=".//mstns:Pedimento" /&gt;
&lt;xs:field xpath="mstns:Proveedor" /&gt;
&lt;xs:field xpath="Remision" /&gt;
&lt;/xs:keyref&gt;
&lt;xs:keyref name="RemisionPedidos" refer="DSCargaRemisionProvKey1"&gt;
&lt;xs:selector xpath=".//mstns:Pedidos" /&gt;
&lt;xs:field xpath="mstns:Proveedor" /&gt;
&lt;xs:field xpath="Remision" /&gt;
&lt;/xs:keyref&gt;
&lt;xs:keyref name="PedidosArticulos" refer="DSCargaRemisionProvKey4"&gt;
&lt;xs:selector xpath=".//mstns:Articulos" /&gt;
&lt;xs:field xpath="mstns:Proveedor" /&gt;
&lt;xs:field xpath="Remision" /&gt;
&lt;xs:field xpath="mstns:FolioPedido" /&gt;
&lt;/xs:keyref&gt;
&lt;xs:key name="DSCargaRemisionProvKey6" msdata:PrimaryKey="true"&gt;
&lt;xs:selector xpath=".//mstns:Articulos" /&gt;
&lt;xs:field xpath="mstns:Proveedor" /&gt;
&lt;xs:field xpath="Remision" /&gt;
&lt;xs:field xpath="mstns:FolioPedido" /&gt;
&lt;xs:field xpath="mstns:Tienda" /&gt;
&lt;xs:field xpath="mstns:Codigo" /&gt;
&lt;/xs:key&gt;
&lt;/xs:element&gt;
&lt;/xs:schema&gt;

feyd | Please use

Code: Select all

and

Code: Select all

tags where approriate when posting code. Read:  [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url][/color]

Posted: Mon Aug 16, 2004 6:33 pm
by hserna
Hi again!

Here is more info.

It seems like I have to use dataset type:

CargaRemision(DataSet dsCargaRemision, String Usuario, String Contrasena).

But still don't know how.

(I don't care if the solution uses PEAR:SOAP or NUSOAP... thanks)