Lad os tage et lille C# eksempel (du kan nemt læse det selvom du koder i C++ eller Java).
[Serializable]
public class Rec
{
private int f1;
private string f2;
public Rec() : this(0, "")
{
}
public Rec(int f1, string f2)
{
this.f1 = f1;
this.f2 = f2;
}
public int F1
{
get
{
return f1;
}
set
{
f1 = value;
}
}
public string F2
{
get
{
return f2;
}
set
{
f2 = value;
}
}
}
public class DataGateway
{
[WebMethod]
public Rec[] GetAll()
{
// implementationen er mindre vigtig
}
}
vi kalder en metode GetAll som returnerer et array af en klasse Rec med 2 properties F1 og F2.
SOAP request ser ud som:
<?xml version="1.0" encoding="utf-8"?>
<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/"> <soap:Body>
<GetAll xmlns="
http://tempuri.org/" />
</soap:Body>
</soap:Envelope>
SOAP response ser ud som:
<?xml version="1.0" encoding="utf-8"?>
<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/"> <soap:Body>
<GetAllResponse xmlns="
http://tempuri.org/"> <GetAllResult>
<Rec>
<F1>1</F1>
<F2>A</F2>
</Rec>
<Rec>
<F1>2</F1>
<F2>BB</F2>
</Rec>
</GetAllResult>
</GetAllResponse>
</soap:Body>
</soap:Envelope>