SOAP: Difference between revisions

1,643 bytes added ,  5 years ago
Added Go
(added Perl 6)
(Added Go)
Line 142:
let result = Wsdl.soapFunc("hello")
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}}==
9,485

edits