Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

VBScript and SOAP Problem

Status
Not open for further replies.

Horsegag9

Technical User
Jan 25, 2005
9
0
0
AU
Hey All,

I have the below script on a field that is used to make a call using webservices and then pull back the result from that call and populate the field. The script on the field is thus:

On Error Resume Next

Dim oSOAP
Set oSOAP = CreateObject("MSSOAP.SoapClient30")
oSOAP.ClientProperty("ServerHTTPRequest") = True
oSOAP.mssoapinit("
If err <> 0 Then
err_mess = err.Description & vbLf & _
err.Source & vbLf & _
oSOAP.FaultCode & vbLf & _
oSOAP.FaultString
MsgBox err_mess
Else
MsgBox "Connection initialized"
'msgbox "Temperature in fahrenheit: " & oSOAP.cels2fahr(CDbl(20))
MsgBox "Web Service reply : " & oSOAP.GetVendorName
If err <> 0 Then
err_mess = err.Description & vbLf & _
err.Source & vbLf & _
oSOAP.FaultCode & vbLf & _
oSOAP.FaultString
End If
End If


=================================

The ASMX file has the following code behind it:

using System;
using System.Collections;
using System.ComponentModel;
using System.Data;
using System.Diagnostics;
using System.Web;
using System.Web.Services;
using System.Configuration;



namespace F0101WS
{
/// <summary>
/// Summary description for Service1.
/// </summary>
public class F0101WS : System.Web.Services.WebService
{
public F0101WS()
{
//CODEGEN: This call is required by the ASP.NET Web Services Designer
InitializeComponent();
}

private System.Data.OleDb.OleDbConnection conn = new System.Data.OleDb.OleDbConnection();
private System.Data.OleDb.OleDbCommand cmd = new System.Data.OleDb.OleDbCommand();

#region Component Designer generated code

//Required by the Web Services Designer
private IContainer components = null;

/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.conn = new System.Data.OleDb.OleDbConnection();
this.cmd = new System.Data.OleDb.OleDbCommand();
//
// conn
//

}

/// <summary>
/// Clean up any resources being used.
/// </summary>
protected override void Dispose( bool disposing )
{
if(disposing && components != null)
{
components.Dispose();
}
base.Dispose(disposing);
}

#endregion



[WebMethod]
public string GetVendorNumber(string vendorName)
{
string retval = "";
try
{
conn.ConnectionString = ConfigurationSettings.AppSettings["JDEAccess.ConnectionString"].ToString();
cmd.Connection = this.conn;
cmd.CommandText = "Select ABAN8 from F0101 where ABALPH Like '%" + vendorName + "'%";
conn.Open();
retval = Convert.ToString(cmd.ExecuteScalar());
}
catch (System.Exception ex)
{throw new Exception(ex.Message);}
finally
{conn.Close();}
if (retval == "")
retval = "Vendor Name Not Found";
return retval;
}


}
}
========================================

Can anybody assist in making this script work? I believe the ASMX file is fine but I can't seem to get anything to work. Any replies are greatly appreciated.

Horse
 
Horsegag9,

[1] Take out the "on error resume next" and let the script fail to see what is the error. [2] The method is GetVendorNumber with an argument, rather than GetVendorName?

regards - tsuji (guessing)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top