SOAP: Difference between revisions
Content added Content deleted
(added Perl 6) |
(Added Go) |
||
Line 142: | Line 142: | ||
let result = Wsdl.soapFunc("hello") |
let result = Wsdl.soapFunc("hello") |
||
let result2 = Wsdl.anotherSoapFunc(34234)</lang> |
let result2 = Wsdl.anotherSoapFunc(34234)</lang> |
||
=={{header|Go}}== |
|||
{{libheader|Go Soap}} |
|||
<br> |
|||
To make this example a bit more interesting we test against a publicly available working soap server at the date of posting. |
|||
<lang go>package main |
|||
import ( |
|||
"fmt" |
|||
"github.com/tiaguinho/gosoap" |
|||
"log" |
|||
) |
|||
type CheckVatResponse struct { |
|||
CountryCode string `xml:"countryCode"` |
|||
VatNumber string `xml:"vatNumber"` |
|||
RequestDate string `xml:"requestDate"` |
|||
Valid string `xml:"valid"` |
|||
Name string `xml:"name"` |
|||
Address string `xml:"address"` |
|||
} |
|||
var ( |
|||
rv CheckVatResponse |
|||
) |
|||
func check(err error) { |
|||
if err != nil { |
|||
log.Fatal(err) |
|||
} |
|||
} |
|||
func main() { |
|||
// create SOAP client |
|||
soap, err := gosoap.SoapClient("http://ec.europa.eu/taxation_customs/vies/checkVatService.wsdl") |
|||
// map parameter names to values |
|||
params := gosoap.Params{ |
|||
"vatNumber": "6388047V", |
|||
"countryCode": "IE", |
|||
} |
|||
// call 'checkVat' function |
|||
err = soap.Call("checkVat", params) |
|||
check(err) |
|||
// unmarshal response to 'rv' |
|||
err = soap.Unmarshal(&rv) |
|||
check(err) |
|||
// print response |
|||
fmt.Println("Country Code : ", rv.CountryCode) |
|||
fmt.Println("Vat Number : ", rv.VatNumber) |
|||
fmt.Println("Request Date : ", rv.RequestDate) |
|||
fmt.Println("Valid : ", rv.Valid) |
|||
fmt.Println("Name : ", rv.Name) |
|||
fmt.Println("Address : ", rv.Address) |
|||
}</lang> |
|||
{{out}} |
|||
<pre> |
|||
Country Code : IE |
|||
Vat Number : 6388047V |
|||
Request Date : 2019-02-08+01:00 |
|||
Valid : true |
|||
Name : GOOGLE IRELAND LIMITED |
|||
Address : 3RD FLOOR, GORDON HOUSE, BARROW STREET, DUBLIN 4 |
|||
</pre> |
|||
==Icon and {{header|Unicon}}== |
==Icon and {{header|Unicon}}== |