tiaguinho / gosoap

🦉SOAP package for Go
MIT License
507 stars 176 forks source link

Expected element type <Envelope> but have <html> #93

Open abhishek-vaishnav-VTS opened 1 year ago

abhishek-vaishnav-VTS commented 1 year ago

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?

chirag-parmar-vts commented 1 year ago

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.

abhishek-vaishnav-VTS commented 1 year ago

@tiaguinho can you please look into it if it seems OK to you as well?

all2ham commented 6 months ago

@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