Problems Consuming Web Services

B

bob garbados

I'm new to web services and I'm trying to interface with a payment gateway
for an online store. I'm trying to do this without Visual Studio and I'm
stuck...

I created my proxy class from the command line with the following statement:
wsdl
https://webservices.innovativegateway.com/igspaymentservice/igspaymentservice.asmx?WSDL
/l:vb /n:ECommerce.PaymentGateway /o:ECommerce.PaymentGateway.vb

I then compiled it into a dll along with some other classes using the
following statement:
vbc /t:library /out:..\bin\ECommerce.dll /r:System.xml.dll
/r:Microsoft.VisualBasic.dll /r:System.dll /r:System.Data.dll
/r:System.Web.dll /r:System.Web.Services.dll ECommerce.Utils.vb
Ecommerce.DataAccess.vb ECommerce.PaymentGateway.vb

The Web Service contains two methods... GetVersion and ProcessTransaction.
I can call GetVersion without a hitch, but I'm getting the following error
when I try to call ProcessTransaction:
BC30311: Value of type 'System.Collections.Hashtable' cannot be converted
to '1-dimensional array of ECommerce.PaymentGateway.IGSParameter'.

Here's the function generated by wisdl:

<System.Web.Services.Protocols.SoapDocumentMethodAttribute("http://WebServic
es.InnovativeGateway.com/IGS/IGSPaymentService/ProcessTransaction"& _
"",
RequestNamespace:="http://WebServices.InnovativeGateway.com/IGS/IGSPaymentSe
rvice/",
ResponseNamespace:="http://WebServices.InnovativeGateway.com/IGS/IGSPaymentS
ervice/", Use:=System.Web.Services.Description.SoapBindingUse.Literal,
ParameterStyle:=System.Web.Services.Protocols.SoapParameterStyle.Wrapped)>
_
Public Function
ProcessTransaction(<System.Xml.Serialization.XmlArrayItemAttribute(IsNullabl
e:=false)> ByVal pInput() As IGSParameter) As
<System.Xml.Serialization.XmlArrayItemAttribute(IsNullable:=false)>
IGSParameter()
Dim results() As Object = Me.Invoke("ProcessTransaction", New
Object() {pInput})
Return CType(results(0),IGSParameter())
End Function

And here's the IGSParameter class:
Public Class IGSParameter

'<remarks/>
Public Name As String

'<remarks/>
Public Value As String
End Class
I followed the C# example that the payment gateway provided... Sorry for the
length of this post, but I'm going to include some code.

Here's my vb code:
Function ProcessTransaction() as Boolean
Dim blnSuccess as Boolean
blnSuccess = True

Dim pgInnovative as IGSPaymentService
pgInnovative = new IGSPaymentService

Dim strVersion as String
strVersion = pgInnovative.GetVersion().ToString()
lblDebug.Text = strVersion

'Create a hash table to contain name/value pairs for innovative inputs
Dim htInnovativeGatewayFields as HashTable
htInnovativeGatewayFields = New HashTable()

htInnovativeGatewayFields.Add("target_app", "WebCharge_v5.06")
htInnovativeGatewayFields.Add("upg_auth", "zxcvlkjh")
If Not Session("CCType") Is Nothing Then
htInnovativeGatewayFields.Add("cardtype", Session("CCType"))
Else
blnSuccess = False
End If
....
htInnovativeGatewayFields.Add("NotifyEmail", "no")
htInnovativeGatewayFields.Add("ReceipEmail", "no")

If blnSuccess = False Then
return False
End If

CODE FAILS HERE
htInnovativeGatewayFields =
pgInnovative.ProcessTransaction(htInnovativeGatewayFields)
lblDebug.Text = htInnovativeGatewayFields.ToString()

htInnovativeGatewayFields.Clear

return blnSuccess

End Function

And here's the relevant parts of the example code:

UpgiClient uc = new UpgiClient();

// create a Hashtable object for holding the name/value pairs
Hashtable ht = new Hashtable();

private void Page_Load(object sender, System.EventArgs e)
{
// initialize the Hashtable with the transaction information
ht["cardtype"] = "visa";
ht["ccname"] = "John Smith";
ht["ccnumber"] = "4242424242424242";
ht["fulltotal"] = "2.00";
ht["month"] = "12";
ht["year"] = "05";
ht["trantype"] = "sale";
ht["baddress"] = "1001 Main";
ht["bcity"] = "Dallas";
ht["bstate"] = "TX";
ht["bzip"] = "75240";
ht["bphone"] = "2145557177";
ht["ordernumber"] = "11A442B11";

resultsgood.Visible = false;
resultsbad.Visible = false;

}

private void Go_Click(object sender, System.EventArgs e)
{
ht["username"] = user.Text;
ht["pw"] = pass.Text;

// process the transaction and retrieve the results back into the
Hashtable
ht = uc.ProcessTransaction(ht);

String Output = "";

// dump out the contents of the Hashtable just to see what's in there
foreach( string key in ht.Keys ) {
Output = Output + key + " = ";
Output = Output + ht[key] + " \n";
}

results.Text = Output;

// check for success or failure
if( ht.ContainsKey("error") )
{
results.ForeColor = System.Drawing.Color.Red;
resultsbad.Visible = true;
resultsgood.Visible = false;
}
else
{
results.ForeColor = System.Drawing.Color.Green;
resultsgood.Visible = true;
resultsbad.Visible = false;
}
}

}
}


Can anybody see what am I doing wrong here (or even follow this post)? The
example uses a hashtable, but it's not working...

thanks in advance.
 
A

Alvin Bruney [MVP]

is your htInnovativeGatewayFields the same type as the return from the
processtransactions? it doesn't seem to be. i looked at the code but the VB
in there started to spin my head.

--
Regards,
Alvin Bruney
[ASP.NET MVP http://mvp.support.microsoft.com/default.aspx]
Got tidbits? Get it here... http://tinyurl.com/27cok
bob garbados said:
I'm new to web services and I'm trying to interface with a payment gateway
for an online store. I'm trying to do this without Visual Studio and I'm
stuck...

I created my proxy class from the command line with the following
statement:
wsdl
https://webservices.innovativegateway.com/igspaymentservice/igspaymentservice.asmx?WSDL
/l:vb /n:ECommerce.PaymentGateway /o:ECommerce.PaymentGateway.vb

I then compiled it into a dll along with some other classes using the
following statement:
vbc /t:library /out:..\bin\ECommerce.dll /r:System.xml.dll
/r:Microsoft.VisualBasic.dll /r:System.dll /r:System.Data.dll
/r:System.Web.dll /r:System.Web.Services.dll ECommerce.Utils.vb
Ecommerce.DataAccess.vb ECommerce.PaymentGateway.vb

The Web Service contains two methods... GetVersion and ProcessTransaction.
I can call GetVersion without a hitch, but I'm getting the following error
when I try to call ProcessTransaction:
BC30311: Value of type 'System.Collections.Hashtable' cannot be converted
to '1-dimensional array of ECommerce.PaymentGateway.IGSParameter'.

Here's the function generated by wisdl:

<System.Web.Services.Protocols.SoapDocumentMethodAttribute("http://WebServic
es.InnovativeGateway.com/IGS/IGSPaymentService/ProcessTransaction"& _
"",
RequestNamespace:="http://WebServices.InnovativeGateway.com/IGS/IGSPaymentSe
rvice/",
ResponseNamespace:="http://WebServices.InnovativeGateway.com/IGS/IGSPaymentS
ervice/", Use:=System.Web.Services.Description.SoapBindingUse.Literal,
ParameterStyle:=System.Web.Services.Protocols.SoapParameterStyle.Wrapped)>
_
Public Function
ProcessTransaction(<System.Xml.Serialization.XmlArrayItemAttribute(IsNullabl
e:=false)> ByVal pInput() As IGSParameter) As
<System.Xml.Serialization.XmlArrayItemAttribute(IsNullable:=false)>
IGSParameter()
Dim results() As Object = Me.Invoke("ProcessTransaction", New
Object() {pInput})
Return CType(results(0),IGSParameter())
End Function

And here's the IGSParameter class:
Public Class IGSParameter

'<remarks/>
Public Name As String

'<remarks/>
Public Value As String
End Class
I followed the C# example that the payment gateway provided... Sorry for
the
length of this post, but I'm going to include some code.

Here's my vb code:
Function ProcessTransaction() as Boolean
Dim blnSuccess as Boolean
blnSuccess = True

Dim pgInnovative as IGSPaymentService
pgInnovative = new IGSPaymentService

Dim strVersion as String
strVersion = pgInnovative.GetVersion().ToString()
lblDebug.Text = strVersion

'Create a hash table to contain name/value pairs for innovative inputs
Dim htInnovativeGatewayFields as HashTable
htInnovativeGatewayFields = New HashTable()

htInnovativeGatewayFields.Add("target_app", "WebCharge_v5.06")
htInnovativeGatewayFields.Add("upg_auth", "zxcvlkjh")
If Not Session("CCType") Is Nothing Then
htInnovativeGatewayFields.Add("cardtype", Session("CCType"))
Else
blnSuccess = False
End If
...
htInnovativeGatewayFields.Add("NotifyEmail", "no")
htInnovativeGatewayFields.Add("ReceipEmail", "no")

If blnSuccess = False Then
return False
End If

CODE FAILS HERE
htInnovativeGatewayFields =
pgInnovative.ProcessTransaction(htInnovativeGatewayFields)
lblDebug.Text = htInnovativeGatewayFields.ToString()

htInnovativeGatewayFields.Clear

return blnSuccess

End Function

And here's the relevant parts of the example code:

UpgiClient uc = new UpgiClient();

// create a Hashtable object for holding the name/value pairs
Hashtable ht = new Hashtable();

private void Page_Load(object sender, System.EventArgs e)
{
// initialize the Hashtable with the transaction information
ht["cardtype"] = "visa";
ht["ccname"] = "John Smith";
ht["ccnumber"] = "4242424242424242";
ht["fulltotal"] = "2.00";
ht["month"] = "12";
ht["year"] = "05";
ht["trantype"] = "sale";
ht["baddress"] = "1001 Main";
ht["bcity"] = "Dallas";
ht["bstate"] = "TX";
ht["bzip"] = "75240";
ht["bphone"] = "2145557177";
ht["ordernumber"] = "11A442B11";

resultsgood.Visible = false;
resultsbad.Visible = false;

}

private void Go_Click(object sender, System.EventArgs e)
{
ht["username"] = user.Text;
ht["pw"] = pass.Text;

// process the transaction and retrieve the results back into the
Hashtable
ht = uc.ProcessTransaction(ht);

String Output = "";

// dump out the contents of the Hashtable just to see what's in there
foreach( string key in ht.Keys ) {
Output = Output + key + " = ";
Output = Output + ht[key] + " \n";
}

results.Text = Output;

// check for success or failure
if( ht.ContainsKey("error") )
{
results.ForeColor = System.Drawing.Color.Red;
resultsbad.Visible = true;
resultsgood.Visible = false;
}
else
{
results.ForeColor = System.Drawing.Color.Green;
resultsgood.Visible = true;
resultsbad.Visible = false;
}
}

}
}


Can anybody see what am I doing wrong here (or even follow this post)?
The
example uses a hashtable, but it's not working...

thanks in advance.
 
S

Sayed Hashimi

Bob,

I am not sure how the hashtable could've worked because the
ProcessTransaction method is expecting an array of IGSParameter
objects.

Everything you need to call the web service will be defined in the
proxy class. As you pointed out, the IGSParameter class is defined in
the proxy. Why don't you try to create an array of IGSParameter
objects rather than the hashtable.

One more thing, the web service cannot rely on
System.Collections.Hashtable (if that is really what the hashtable you
were refering to) because clients can call web services from any
platform. For example, a java client can call the web service and that
client will not have any knowledge of the hastable.

sayed


bob garbados said:
I'm new to web services and I'm trying to interface with a payment gateway
for an online store. I'm trying to do this without Visual Studio and I'm
stuck...

I created my proxy class from the command line with the following statement:
wsdl
https://webservices.innovativegateway.com/igspaymentservice/igspaymentservice.asmx?WSDL
/l:vb /n:ECommerce.PaymentGateway /o:ECommerce.PaymentGateway.vb

I then compiled it into a dll along with some other classes using the
following statement:
vbc /t:library /out:..\bin\ECommerce.dll /r:System.xml.dll
/r:Microsoft.VisualBasic.dll /r:System.dll /r:System.Data.dll
/r:System.Web.dll /r:System.Web.Services.dll ECommerce.Utils.vb
Ecommerce.DataAccess.vb ECommerce.PaymentGateway.vb

The Web Service contains two methods... GetVersion and ProcessTransaction.
I can call GetVersion without a hitch, but I'm getting the following error
when I try to call ProcessTransaction:
BC30311: Value of type 'System.Collections.Hashtable' cannot be converted
to '1-dimensional array of ECommerce.PaymentGateway.IGSParameter'.

Here's the function generated by wisdl:

<System.Web.Services.Protocols.SoapDocumentMethodAttribute("http://WebServic
es.InnovativeGateway.com/IGS/IGSPaymentService/ProcessTransaction"& _
"",
RequestNamespace:="http://WebServices.InnovativeGateway.com/IGS/IGSPaymentSe
rvice/",
ResponseNamespace:="http://WebServices.InnovativeGateway.com/IGS/IGSPaymentS
ervice/", Use:=System.Web.Services.Description.SoapBindingUse.Literal,
ParameterStyle:=System.Web.Services.Protocols.SoapParameterStyle.Wrapped)>
_
Public Function
ProcessTransaction(<System.Xml.Serialization.XmlArrayItemAttribute(IsNullabl
e:=false)> ByVal pInput() As IGSParameter) As
<System.Xml.Serialization.XmlArrayItemAttribute(IsNullable:=false)>
IGSParameter()
Dim results() As Object = Me.Invoke("ProcessTransaction", New
Object() {pInput})
Return CType(results(0),IGSParameter())
End Function

And here's the IGSParameter class:
Public Class IGSParameter

'<remarks/>
Public Name As String

'<remarks/>
Public Value As String
End Class
I followed the C# example that the payment gateway provided... Sorry for the
length of this post, but I'm going to include some code.

Here's my vb code:
Function ProcessTransaction() as Boolean
Dim blnSuccess as Boolean
blnSuccess = True

Dim pgInnovative as IGSPaymentService
pgInnovative = new IGSPaymentService

Dim strVersion as String
strVersion = pgInnovative.GetVersion().ToString()
lblDebug.Text = strVersion

'Create a hash table to contain name/value pairs for innovative inputs
Dim htInnovativeGatewayFields as HashTable
htInnovativeGatewayFields = New HashTable()

htInnovativeGatewayFields.Add("target_app", "WebCharge_v5.06")
htInnovativeGatewayFields.Add("upg_auth", "zxcvlkjh")
If Not Session("CCType") Is Nothing Then
htInnovativeGatewayFields.Add("cardtype", Session("CCType"))
Else
blnSuccess = False
End If
...
htInnovativeGatewayFields.Add("NotifyEmail", "no")
htInnovativeGatewayFields.Add("ReceipEmail", "no")

If blnSuccess = False Then
return False
End If

CODE FAILS HERE
htInnovativeGatewayFields =
pgInnovative.ProcessTransaction(htInnovativeGatewayFields)
lblDebug.Text = htInnovativeGatewayFields.ToString()

htInnovativeGatewayFields.Clear

return blnSuccess

End Function

And here's the relevant parts of the example code:

UpgiClient uc = new UpgiClient();

// create a Hashtable object for holding the name/value pairs
Hashtable ht = new Hashtable();

private void Page_Load(object sender, System.EventArgs e)
{
// initialize the Hashtable with the transaction information
ht["cardtype"] = "visa";
ht["ccname"] = "John Smith";
ht["ccnumber"] = "4242424242424242";
ht["fulltotal"] = "2.00";
ht["month"] = "12";
ht["year"] = "05";
ht["trantype"] = "sale";
ht["baddress"] = "1001 Main";
ht["bcity"] = "Dallas";
ht["bstate"] = "TX";
ht["bzip"] = "75240";
ht["bphone"] = "2145557177";
ht["ordernumber"] = "11A442B11";

resultsgood.Visible = false;
resultsbad.Visible = false;

}

private void Go_Click(object sender, System.EventArgs e)
{
ht["username"] = user.Text;
ht["pw"] = pass.Text;

// process the transaction and retrieve the results back into the
Hashtable
ht = uc.ProcessTransaction(ht);

String Output = "";

// dump out the contents of the Hashtable just to see what's in there
foreach( string key in ht.Keys ) {
Output = Output + key + " = ";
Output = Output + ht[key] + " \n";
}

results.Text = Output;

// check for success or failure
if( ht.ContainsKey("error") )
{
results.ForeColor = System.Drawing.Color.Red;
resultsbad.Visible = true;
resultsgood.Visible = false;
}
else
{
results.ForeColor = System.Drawing.Color.Green;
resultsgood.Visible = true;
resultsbad.Visible = false;
}
}

}
}


Can anybody see what am I doing wrong here (or even follow this post)? The
example uses a hashtable, but it's not working...

thanks in advance.
 
B

bob garbados

The example code that the payment gateway provided me with used a hashtable,
but I guess it should be obvious that I should be using the IGSParameter.
So here's where I get stuck...

I need to call this method of the webservice:
Public Function ProcessTransaction(ByVal pInput() As IGSParameter) As
IGSParameter()
Dim results() As Object = Me.Invoke("ProcessTransaction", New
Object() {pInput})
Return CType(results(0),IGSParameter())
End Function

Which uses the following class as input/output:
Public Class IGSParameter
Public Name() As String
Public Value() As String
End Class

How do I assign name/values to the array of IGSParameters and how do I call
the actual webservice? When I use the code below I get the error BC30311:
Value of type 'String' cannot be converted to '1-dimensional array of
String' trying to assign the values to the igsInput. The call to
ProcessTransaction gives the error BC30105: Number of indices is less than
the number of dimensions of the indexed array.

Dim pgInnovative as IgsPaymentService
pgInnovative = new IgsPaymentService

Dim igsInput(2) as IgsParameter
igsInput(0) = new IgsParameter()
igsInput(0).Name = "some_name"
igsInput(0).Value = "some_value"
igsInput() = pgInnovative.ProcessTransaction(igsInput())


Sayed Hashimi said:
Bob,

I am not sure how the hashtable could've worked because the
ProcessTransaction method is expecting an array of IGSParameter
objects.

Everything you need to call the web service will be defined in the
proxy class. As you pointed out, the IGSParameter class is defined in
the proxy. Why don't you try to create an array of IGSParameter
objects rather than the hashtable.

One more thing, the web service cannot rely on
System.Collections.Hashtable (if that is really what the hashtable you
were refering to) because clients can call web services from any
platform. For example, a java client can call the web service and that
client will not have any knowledge of the hastable.

sayed


"bob garbados" <[email protected]> wrote in message
I'm new to web services and I'm trying to interface with a payment gateway
for an online store. I'm trying to do this without Visual Studio and I'm
stuck...

I created my proxy class from the command line with the following statement:
wsdl
https://webservices.innovativegateway.com/igspaymentservice/igspaymentservice.asmx?WSDL
/l:vb /n:ECommerce.PaymentGateway /o:ECommerce.PaymentGateway.vb

I then compiled it into a dll along with some other classes using the
following statement:
vbc /t:library /out:..\bin\ECommerce.dll /r:System.xml.dll
/r:Microsoft.VisualBasic.dll /r:System.dll /r:System.Data.dll
/r:System.Web.dll /r:System.Web.Services.dll ECommerce.Utils.vb
Ecommerce.DataAccess.vb ECommerce.PaymentGateway.vb

The Web Service contains two methods... GetVersion and ProcessTransaction.
I can call GetVersion without a hitch, but I'm getting the following error
when I try to call ProcessTransaction:
BC30311: Value of type 'System.Collections.Hashtable' cannot be converted
to '1-dimensional array of ECommerce.PaymentGateway.IGSParameter'.

Here's the function generated by wisdl:

<System.Web.Services.Protocols.SoapDocumentMethodAttribute("http://WebServic
es.InnovativeGateway.com/IGS/IGSPaymentService/ProcessTransaction"& _
"",
RequestNamespace:="http://WebServices.InnovativeGateway.com/IGS/IGSPaymentSe
rvice/",
ResponseNamespace:="http://WebServices.InnovativeGateway.com/IGS/IGSPaymentS
ervice/", Use:=System.Web.Services.Description.SoapBindingUse.Literal,
ParameterStyle:=System.Web.Services.Protocols.SoapParameterStyle.Wrapped)>
_
Public Function
ProcessTransaction(<System.Xml.Serialization.XmlArrayItemAttribute(IsNullabl
e:=false)> ByVal pInput() As IGSParameter) As
<System.Xml.Serialization.XmlArrayItemAttribute(IsNullable:=false)>
IGSParameter()
Dim results() As Object = Me.Invoke("ProcessTransaction", New
Object() {pInput})
Return CType(results(0),IGSParameter())
End Function

And here's the IGSParameter class:
Public Class IGSParameter

'<remarks/>
Public Name As String

'<remarks/>
Public Value As String
End Class
I followed the C# example that the payment gateway provided... Sorry for the
length of this post, but I'm going to include some code.

Here's my vb code:
Function ProcessTransaction() as Boolean
Dim blnSuccess as Boolean
blnSuccess = True

Dim pgInnovative as IGSPaymentService
pgInnovative = new IGSPaymentService

Dim strVersion as String
strVersion = pgInnovative.GetVersion().ToString()
lblDebug.Text = strVersion

'Create a hash table to contain name/value pairs for innovative inputs
Dim htInnovativeGatewayFields as HashTable
htInnovativeGatewayFields = New HashTable()

htInnovativeGatewayFields.Add("target_app", "WebCharge_v5.06")
htInnovativeGatewayFields.Add("upg_auth", "zxcvlkjh")
If Not Session("CCType") Is Nothing Then
htInnovativeGatewayFields.Add("cardtype", Session("CCType"))
Else
blnSuccess = False
End If
...
htInnovativeGatewayFields.Add("NotifyEmail", "no")
htInnovativeGatewayFields.Add("ReceipEmail", "no")

If blnSuccess = False Then
return False
End If

CODE FAILS HERE
htInnovativeGatewayFields =
pgInnovative.ProcessTransaction(htInnovativeGatewayFields)
lblDebug.Text = htInnovativeGatewayFields.ToString()

htInnovativeGatewayFields.Clear

return blnSuccess

End Function

And here's the relevant parts of the example code:

UpgiClient uc = new UpgiClient();

// create a Hashtable object for holding the name/value pairs
Hashtable ht = new Hashtable();

private void Page_Load(object sender, System.EventArgs e)
{
// initialize the Hashtable with the transaction information
ht["cardtype"] = "visa";
ht["ccname"] = "John Smith";
ht["ccnumber"] = "4242424242424242";
ht["fulltotal"] = "2.00";
ht["month"] = "12";
ht["year"] = "05";
ht["trantype"] = "sale";
ht["baddress"] = "1001 Main";
ht["bcity"] = "Dallas";
ht["bstate"] = "TX";
ht["bzip"] = "75240";
ht["bphone"] = "2145557177";
ht["ordernumber"] = "11A442B11";

resultsgood.Visible = false;
resultsbad.Visible = false;

}

private void Go_Click(object sender, System.EventArgs e)
{
ht["username"] = user.Text;
ht["pw"] = pass.Text;

// process the transaction and retrieve the results back into the
Hashtable
ht = uc.ProcessTransaction(ht);

String Output = "";

// dump out the contents of the Hashtable just to see what's in there
foreach( string key in ht.Keys ) {
Output = Output + key + " = ";
Output = Output + ht[key] + " \n";
}

results.Text = Output;

// check for success or failure
if( ht.ContainsKey("error") )
{
results.ForeColor = System.Drawing.Color.Red;
resultsbad.Visible = true;
resultsgood.Visible = false;
}
else
{
results.ForeColor = System.Drawing.Color.Green;
resultsgood.Visible = true;
resultsbad.Visible = false;
}
}

}
}


Can anybody see what am I doing wrong here (or even follow this post)? The
example uses a hashtable, but it's not working...

thanks in advance.
 
S

Sayed Hashimi

Bob,

You can create the array and call the method as follows:

' dim the parameter array
Dim parms(0) As IGSParameter
' dim name and value array
Dim names(1) As String
Dim values(1) As String

' create name/value
names(0) = "name 1"
values(0) = "value 1"
'
names(1) = "name 2"
values(1) = "value 2"
' create an instance of IGSParameter and
' assign the arrays
parms(0) = New IGSParameter
parms(0).Name = names
parms(0).Value = values
' call ProcessTransaction
ProcessTransaction(parms)


sayed


bob garbados said:
The example code that the payment gateway provided me with used a hashtable,
but I guess it should be obvious that I should be using the IGSParameter.
So here's where I get stuck...

I need to call this method of the webservice:
Public Function ProcessTransaction(ByVal pInput() As IGSParameter) As
IGSParameter()
Dim results() As Object = Me.Invoke("ProcessTransaction", New
Object() {pInput})
Return CType(results(0),IGSParameter())
End Function

Which uses the following class as input/output:
Public Class IGSParameter
Public Name() As String
Public Value() As String
End Class

How do I assign name/values to the array of IGSParameters and how do I call
the actual webservice? When I use the code below I get the error BC30311:
Value of type 'String' cannot be converted to '1-dimensional array of
String' trying to assign the values to the igsInput. The call to
ProcessTransaction gives the error BC30105: Number of indices is less than
the number of dimensions of the indexed array.

Dim pgInnovative as IgsPaymentService
pgInnovative = new IgsPaymentService

Dim igsInput(2) as IgsParameter
igsInput(0) = new IgsParameter()
igsInput(0).Name = "some_name"
igsInput(0).Value = "some_value"
igsInput() = pgInnovative.ProcessTransaction(igsInput())


Sayed Hashimi said:
Bob,

I am not sure how the hashtable could've worked because the
ProcessTransaction method is expecting an array of IGSParameter
objects.

Everything you need to call the web service will be defined in the
proxy class. As you pointed out, the IGSParameter class is defined in
the proxy. Why don't you try to create an array of IGSParameter
objects rather than the hashtable.

One more thing, the web service cannot rely on
System.Collections.Hashtable (if that is really what the hashtable you
were refering to) because clients can call web services from any
platform. For example, a java client can call the web service and that
client will not have any knowledge of the hastable.

sayed


"bob garbados" <[email protected]> wrote in message
I'm new to web services and I'm trying to interface with a payment gateway
for an online store. I'm trying to do this without Visual Studio and I'm
stuck...

I created my proxy class from the command line with the following statement:
wsdl
https://webservices.innovativegateway.com/igspaymentservice/igspaymentservice.asmx?WSDL
/l:vb /n:ECommerce.PaymentGateway /o:ECommerce.PaymentGateway.vb

I then compiled it into a dll along with some other classes using the
following statement:
vbc /t:library /out:..\bin\ECommerce.dll /r:System.xml.dll
/r:Microsoft.VisualBasic.dll /r:System.dll /r:System.Data.dll
/r:System.Web.dll /r:System.Web.Services.dll ECommerce.Utils.vb
Ecommerce.DataAccess.vb ECommerce.PaymentGateway.vb

The Web Service contains two methods... GetVersion and ProcessTransaction.
I can call GetVersion without a hitch, but I'm getting the following error
when I try to call ProcessTransaction:
BC30311: Value of type 'System.Collections.Hashtable' cannot be converted
to '1-dimensional array of ECommerce.PaymentGateway.IGSParameter'.

Here's the function generated by wisdl:

<System.Web.Services.Protocols.SoapDocumentMethodAttribute("http://WebServic
es.InnovativeGateway.com/IGS/IGSPaymentService/ProcessTransaction"& _
"",
RequestNamespace:="http://WebServices.InnovativeGateway.com/IGS/IGSPaymentSe
rvice/",
ResponseNamespace:="http://WebServices.InnovativeGateway.com/IGS/IGSPaymentS
ervice/", Use:=System.Web.Services.Description.SoapBindingUse.Literal,
ParameterStyle:=System.Web.Services.Protocols.SoapParameterStyle.Wrapped)>
_
Public Function
ProcessTransaction(<System.Xml.Serialization.XmlArrayItemAttribute(IsNullabl
e:=false)> ByVal pInput() As IGSParameter) As
<System.Xml.Serialization.XmlArrayItemAttribute(IsNullable:=false)>
IGSParameter()
Dim results() As Object = Me.Invoke("ProcessTransaction", New
Object() {pInput})
Return CType(results(0),IGSParameter())
End Function

And here's the IGSParameter class:
Public Class IGSParameter

'<remarks/>
Public Name As String

'<remarks/>
Public Value As String
End Class
I followed the C# example that the payment gateway provided... Sorry for the
length of this post, but I'm going to include some code.

Here's my vb code:
Function ProcessTransaction() as Boolean
Dim blnSuccess as Boolean
blnSuccess = True

Dim pgInnovative as IGSPaymentService
pgInnovative = new IGSPaymentService

Dim strVersion as String
strVersion = pgInnovative.GetVersion().ToString()
lblDebug.Text = strVersion

'Create a hash table to contain name/value pairs for innovative inputs
Dim htInnovativeGatewayFields as HashTable
htInnovativeGatewayFields = New HashTable()

htInnovativeGatewayFields.Add("target_app", "WebCharge_v5.06")
htInnovativeGatewayFields.Add("upg_auth", "zxcvlkjh")
If Not Session("CCType") Is Nothing Then
htInnovativeGatewayFields.Add("cardtype", Session("CCType"))
Else
blnSuccess = False
End If
...
htInnovativeGatewayFields.Add("NotifyEmail", "no")
htInnovativeGatewayFields.Add("ReceipEmail", "no")

If blnSuccess = False Then
return False
End If

CODE FAILS HERE
htInnovativeGatewayFields =
pgInnovative.ProcessTransaction(htInnovativeGatewayFields)
lblDebug.Text = htInnovativeGatewayFields.ToString()

htInnovativeGatewayFields.Clear

return blnSuccess

End Function

And here's the relevant parts of the example code:

UpgiClient uc = new UpgiClient();

// create a Hashtable object for holding the name/value pairs
Hashtable ht = new Hashtable();

private void Page_Load(object sender, System.EventArgs e)
{
// initialize the Hashtable with the transaction information
ht["cardtype"] = "visa";
ht["ccname"] = "John Smith";
ht["ccnumber"] = "4242424242424242";
ht["fulltotal"] = "2.00";
ht["month"] = "12";
ht["year"] = "05";
ht["trantype"] = "sale";
ht["baddress"] = "1001 Main";
ht["bcity"] = "Dallas";
ht["bstate"] = "TX";
ht["bzip"] = "75240";
ht["bphone"] = "2145557177";
ht["ordernumber"] = "11A442B11";

resultsgood.Visible = false;
resultsbad.Visible = false;

}

private void Go_Click(object sender, System.EventArgs e)
{
ht["username"] = user.Text;
ht["pw"] = pass.Text;

// process the transaction and retrieve the results back into the
Hashtable
ht = uc.ProcessTransaction(ht);

String Output = "";

// dump out the contents of the Hashtable just to see what's in there
foreach( string key in ht.Keys ) {
Output = Output + key + " = ";
Output = Output + ht[key] + " \n";
}

results.Text = Output;

// check for success or failure
if( ht.ContainsKey("error") )
{
results.ForeColor = System.Drawing.Color.Red;
resultsbad.Visible = true;
resultsgood.Visible = false;
}
else
{
results.ForeColor = System.Drawing.Color.Green;
resultsgood.Visible = true;
resultsbad.Visible = false;
}
}
}
}


Can anybody see what am I doing wrong here (or even follow this post)? The
example uses a hashtable, but it's not working...

thanks in advance.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,994
Messages
2,570,223
Members
46,812
Latest member
GracielaWa

Latest Threads

Top