Expected element type <Envelope> but have <html>
Opened this issue · 3 comments
I'm trying to connect to this sample soap API server (https://www.w3schools.com/xml/tempconvert.asmx) but the soap.Call
method always results in this error "expected element type <Envelope>
but have <html>
"
Following is my code snippet,
httpClient := &http.Client{
Timeout: 1500 * time.Millisecond,
}
soap, err := gosoap.SoapClient("https://www.w3schools.com/xml/tempconvert.asmx?wsdl", httpClient)
if err != nil {
fmt.Println("error occurred: ", err)
return
}
params := gosoap.Params{
"Celsius": 500,
}
res, err := soap.Call("CelsiusToFahrenheit", params)
if err != nil {
fmt.Println("error occurred while fetching response: ", err)
return
}
Can anyone help?
I have opened up a pull request for the same here. Basically we need to extract soap URL instead of fetching it from wsdl definition. There are cases where the actual URL starts with https
but it starts with http
in wsdl definition. In this case, httpClient will try to invoke https
URL with http
which would result in above error.
@tiaguinho can you please look into it if it seems OK to you as well?
@abhishek-vaishnav-VTS @chirag-parmar-vts what did you guys end up doing to get around this? Any chance you know of a fork or different SOAP package