Consuming a web service with Classic ASP

Discussion in 'ASP.NET WebServices' started by martincl, May 13, 2010.

  1. Hi everyone,

    I've been trying for about 2 hours to figure out why I get the following error when I try to consume a web service located at another site:

    Could not create an object of type 'MSSOAP.SoapClient'.

    The site works great on all my machines here however once I upload it to discountasp.net, I receive the error above.

    Below is some test code I use to consume the web service:

    Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click
    Try
    Dim s As String

    Dim ds As New Data.DataSet
    'Using classic asp code because the URL can change from agency to agency
    Dim objSoapClient = Server.CreateObject("MSSOAP.SoapClient")
    objSoapClient.ClientProperty("ServerHTTPRequest") = True

    'needs to be updated with the url of the Web Service WSDL and is
    'followed by the Web Service name
    Call objSoapClient.mssoapinit(txtURL.Text)

    'using the SOAP object to call the Web Method Required
    'Since we don't have access to this data, we will have to pass
    'username and password provided by the agency

    s = objSoapClient.VendorQuery(txtVendorID.Text, txtAgencyKey.Text, txtReportNumber.Text, txtParameterString.Text)
    'create an instance of the object containing the deserialized object
    Dim x As System.Xml.Serialization.XmlSerializer = New System.Xml.Serialization.XmlSerializer(ds.GetType)
    'read the serialized string
    Dim sr As New IO.StringReader(s)
    'deserialize and cast the object into the dataset
    ds = CType(x.Deserialize(sr), Data.DataSet)

    GridView1.Visible = True
    Label1.Text = Nothing

    GridView1.DataSource = ds
    GridView1.DataBind()
    Catch ex As Exception
    GridView1.Visible = False
    Label1.Text = ex.Message
    End Try
    End Sub
     
  2. Btw, I downloaded and installed the SOAP ToolKit 3.0 so this line should be changed from:

    Dim objSoapClient = Server.CreateObject("MSSOAP.SoapClient")

    to

    Dim objSoapClient = Server.CreateObject("MSSOAP.SoapClient30")

    I'm thinking that the toolkit isn't installed on the server, hmmmm
     
  3. ...I would have to agree with that but I do not know for sure. ;-)
    You might want to open a support ticket to check.
    All the best,
    Mark
     
  4. Thanks wisemx, I'll do that now. I'm sure that's it. It wouldn't hurt to have it installed on the server anyhow as there are still a vast number of sites that use that technology.
     

Share This Page