473,408 Members | 1,857 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,408 software developers and data experts.

Creating a SOAP Client in VB.Net

I am working on creating a SOAP client in Visual Studio 2008 for the first time but am running into a few issues. I added the Web Service reference to the project and am able to see the namespace and set the information for the classes but cannot figure out how to send the information to the server or receive a response. Below is my code and any help is appreciated!

Expand|Select|Wrap|Line Numbers
  1. Imports Microsoft.Web.Services2
  2.  
  3. Public Class Form1
  4.     Public username As String
  5.     Public password As String
  6.  
  7.     Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
  8.  
  9.         Dim Info As New MYWebService.TransactionInfo
  10.  
  11.         Dim pTamount As Single = "10.00"
  12.         Dim pTmailcode As String = "123456789"
  13.         Dim pTprogramCode As String = "AB"
  14.         Dim pTdonorID As String = "123456789"
  15.         Dim pTfirstName As String = "Test"
  16.         Dim pTmiddleName As String = ""
  17.         Dim pTlastName As String = "Name"
  18.         Dim pTemail As String = ""
  19.         Dim pTcompanyName As String = ""
  20.         Dim pTaddress1 As String = "123 Test Street"
  21.         Dim pTaddress2 As String = ""
  22.         Dim pTcity As String = "Springfield"
  23.         Dim pTstateCode As String = "IN"
  24.         Dim pTzip As String = "12345"
  25.         Dim pTzip4 As String = ""
  26.         Dim pTcountryCode As String = ""
  27.         Dim pTcardNumber As String = "4111111111111111"
  28.         Dim pTcardCSC As String = ""
  29.         Dim pTexpMonth As Integer = "04"
  30.         Dim pTexpYear As Integer = "2010"
  31.         Dim pTrecur As Boolean = "0"
  32.  
  33.         Info.amount = pTamount
  34.         Info.mailcode = pTmailcode
  35.         Info.programCode = pTprogramCode
  36.         Info.donorID = pTdonorID
  37.         Info.firstName = pTfirstName
  38.         Info.middleName = pTmiddleName
  39.         Info.lastName = pTlastName
  40.         Info.email = pTemail
  41.         Info.companyName = pTcompanyName
  42.         Info.address1 = pTaddress1
  43.         Info.address2 = pTaddress2
  44.         Info.city = pTcity
  45.         Info.stateCode = pTstateCode
  46.         Info.zip = pTzip
  47.         Info.zip4 = pTzip4
  48.         Info.countryCode = pTcountryCode
  49.         Info.cardNumber = pTcardNumber
  50.         Info.cardCSC = pTcardCSC
  51.         Info.expMonth = pTexpMonth
  52.         Info.expYear = pTexpYear
  53.         Info.recur = pTrecur
  54.  
  55.         Dim CreateTransaction As New MYWebService.ProcessCardRequest(username, password, "test", Info)
  56.         Dim RecordResponse As New MYWebService.ProcessCardResponse()
  57.         Dim SendRequest As New MYWebService.MYGatewayServicePortTypeClient
  58.  
  59.  
  60.     ****This seems to be where I am stuck... The SendRequest returns the response I guess?****
  61.       SendRequest.Open()
  62.         RecordResponse = SendRequest.MYWebService_MYGatewayServicePortType_ProcessCard(CreateTransaction)
  63.       SendRequest.Close()
  64.  
  65.         MsgBox("")
  66.  
  67.     End Sub
  68.  
  69.     Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
  70.         username = "Username"
  71.         password = "Password"
  72.     End Sub
  73. End Class
  74.  
  75.  
Expand|Select|Wrap|Line Numbers
  1. '------------------------------------------------------------------------------
  2. ' <autogenerated>
  3. '     This code was generated by a tool.
  4. '     Runtime Version: 1.1.4322.2407
  5. '
  6. '     Changes to this file may cause incorrect behavior and will be lost if 
  7. '     the code is regenerated.
  8. ' </autogenerated>
  9. '------------------------------------------------------------------------------
  10.  
  11. Option Strict Off
  12. Option Explicit On
  13.  
  14. Imports Microsoft.Web.Services2
  15. Imports Microsoft.Web.Services2.Addressing
  16. Imports Microsoft.Web.Services2.Messaging
  17. Imports System
  18. Imports System.Xml
  19. Imports System.Xml.Serialization
  20.  
  21. '
  22. 'InfoVersionComment, WseWsdl2, Version=2.0.2.0, Culture=neutral, PublicKeyToken=26ba029e599ec4f8, RunTime Version: 1.1.4322.2407
  23. '
  24.  
  25. '<remarks/>
  26. <System.Xml.Serialization.XmlTypeAttribute([Namespace]:="http://MYgateway.com/xsd6"),  _
  27.  System.Xml.Serialization.XmlRootAttribute("processCardRequest", [Namespace]:="http://www.wso2.org/php/xsd", IsNullable:=false)>  _
  28. Public Class ProcessCardRequest
  29.  
  30.     '<remarks/>
  31.     Public username As String
  32.  
  33.     '<remarks/>
  34.     Public password As String
  35.  
  36.     '<remarks/>
  37.     Public mode As String
  38.  
  39.     '<remarks/>
  40.     Public transactionInfo As TransactionInfo
  41. End Class
  42.  
  43. '<remarks/>
  44. <System.Xml.Serialization.XmlTypeAttribute([Namespace]:="http://MYgateway.com/xsd5")>  _
  45. Public Class TransactionInfo
  46.  
  47.     '<remarks/>
  48.     Public amount As Single
  49.  
  50.     '<remarks/>
  51.     Public mailcode As String
  52.  
  53.     '<remarks/>
  54.     Public programCode As String
  55.  
  56.     '<remarks/>
  57.     Public donorID As String
  58.  
  59.     '<remarks/>
  60.     Public firstName As String
  61.  
  62.     '<remarks/>
  63.     Public middleName As String
  64.  
  65.     '<remarks/>
  66.     Public lastName As String
  67.  
  68.     '<remarks/>
  69.     Public email As String
  70.  
  71.     '<remarks/>
  72.     Public companyName As String
  73.  
  74.     '<remarks/>
  75.     Public address1 As String
  76.  
  77.     '<remarks/>
  78.     Public address2 As String
  79.  
  80.     '<remarks/>
  81.     Public city As String
  82.  
  83.     '<remarks/>
  84.     Public stateCode As String
  85.  
  86.     '<remarks/>
  87.     Public zip As String
  88.  
  89.     '<remarks/>
  90.     Public zip4 As String
  91.  
  92.     '<remarks/>
  93.     Public countryCode As String
  94.  
  95.     '<remarks/>
  96.     Public cardNumber As String
  97.  
  98.     '<remarks/>
  99.     Public cardCSC As String
  100.  
  101.     '<remarks/>
  102.     Public expMonth As Integer
  103.  
  104.     '<remarks/>
  105.     Public expYear As Integer
  106.  
  107.     '<remarks/>
  108.     Public recur As Boolean
  109. End Class
  110.  
  111. '<remarks/>
  112. <System.Xml.Serialization.XmlTypeAttribute([Namespace]:="http://MYgateway.com/xsd7"),  _
  113.  System.Xml.Serialization.XmlRootAttribute("processCardResponse", [Namespace]:="http://www.wso2.org/php/xsd", IsNullable:=false)>  _
  114. Public Class ProcessCardResponse
  115.  
  116.     '<remarks/>
  117.     Public errorCode As Integer
  118.  
  119.     '<remarks/>
  120.     Public errorMsg As String
  121.  
  122.     '<remarks/>
  123.     Public transactionID As String
  124.  
  125.     '<remarks/>
  126.     Public transactionDate As Date
  127.  
  128.     '<remarks/>
  129.     Public donorID As String
  130.  
  131.     '<remarks/>
  132.     Public originalID As String
  133.  
  134.     '<remarks/>
  135.     Public result As Integer
  136.  
  137.     '<remarks/>
  138.     Public responseMsg As String
  139.  
  140.     '<remarks/>
  141.     Public authCode As String
  142.  
  143.     '<remarks/>
  144.     Public profileID As String
  145. End Class
  146.  
  147. '<remarks/>
  148. <System.Xml.Serialization.XmlTypeAttribute([Namespace]:="http://MYgateway.com/xsd6"),  _
  149.  System.Xml.Serialization.XmlRootAttribute("recordGiftRequest", [Namespace]:="http://www.wso2.org/php/xsd", IsNullable:=false)>  _
  150. Public Class RecordGiftRequest
  151.  
  152.     '<remarks/>
  153.     Public username As String
  154.  
  155.     '<remarks/>
  156.     Public password As String
  157.  
  158.     '<remarks/>
  159.     Public mode As String
  160.  
  161.     '<remarks/>
  162.     Public giftInfo As GiftInfo
  163. End Class
  164.  
  165. '<remarks/>
  166. <System.Xml.Serialization.XmlTypeAttribute([Namespace]:="http://MYgateway.com/xsd5")>  _
  167. Public Class GiftInfo
  168.  
  169.     '<remarks/>
  170.     Public amount As Single
  171.  
  172.     '<remarks/>
  173.     Public mailcode As String
  174.  
  175.     '<remarks/>
  176.     Public programCode As String
  177.  
  178.     '<remarks/>
  179.     Public donorID As String
  180.  
  181.     '<remarks/>
  182.     Public firstName As String
  183.  
  184.     '<remarks/>
  185.     Public middleName As String
  186.  
  187.     '<remarks/>
  188.     Public lastName As String
  189.  
  190.     '<remarks/>
  191.     Public email As String
  192.  
  193.     '<remarks/>
  194.     Public companyName As String
  195.  
  196.     '<remarks/>
  197.     Public address1 As String
  198.  
  199.     '<remarks/>
  200.     Public address2 As String
  201.  
  202.     '<remarks/>
  203.     Public city As String
  204.  
  205.     '<remarks/>
  206.     Public stateCode As String
  207.  
  208.     '<remarks/>
  209.     Public zip As String
  210.  
  211.     '<remarks/>
  212.     Public zip4 As String
  213.  
  214.     '<remarks/>
  215.     Public countryCode As String
  216.  
  217.     '<remarks/>
  218.     Public recur As Boolean
  219. End Class
  220.  
  221. '<remarks/>
  222. <System.Xml.Serialization.XmlTypeAttribute([Namespace]:="http://MYgateway.com/xsd7"),  _
  223.  System.Xml.Serialization.XmlRootAttribute("recordGiftResponse", [Namespace]:="http://www.wso2.org/php/xsd", IsNullable:=false)>  _
  224. Public Class RecordGiftResponse
  225.  
  226.     '<remarks/>
  227.     Public errorCode As Integer
  228.  
  229.     '<remarks/>
  230.     Public errorMsg As String
  231.  
  232.     '<remarks/>
  233.     Public donorID As String
  234.  
  235.     '<remarks/>
  236.     Public originalID As String
  237. End Class
  238.  
  239. <SoapService("http://www.wso2.org/php")> _
  240. Public Class MYGatewayService
  241.     Inherits SoapClient 
  242.  
  243.     Public Sub New()
  244.         MyBase.New(New Uri("http://www.MYgateway.com:443/index.php/svc"))
  245.     End Sub
  246.  
  247.     <SoapMethod("http://www.MYgateway.com:443/index.php/svc/ProcessCard")> _
  248.     Public Function ProcessCard(  request As processCardRequest) As processCardResponse
  249.         Return CType(MyBase.SendRequestResponse("ProcessCard", request).GetBodyObject(GetType(processCardResponse), SoapServiceAttribute.TargetNamespace),processCardResponse)
  250.     End Function
  251.  
  252.     Public Function BeginProcessCard(  request As processCardRequest, callback As System.AsyncCallback, asyncState As Object) As IAsyncResult
  253.         Return MyBase.BeginSendRequestResponse("ProcessCard", request, callback, asyncState)
  254.     End Function
  255.  
  256.     Public Function EndProcessCard( asyncResult As IAsyncResult ) As processCardResponse
  257.         Return CType(MyBase.EndSendRequestResponse(asyncResult).GetBodyObject(GetType(processCardResponse), SoapServiceAttribute.TargetNamespace),processCardResponse)
  258.     End Function
  259.  
  260.     <SoapMethod("http://www.MYgateway.com:443/index.php/svc/RecordGift")> _
  261.     Public Function RecordGift(  request As recordGiftRequest) As recordGiftResponse
  262.         Return CType(MyBase.SendRequestResponse("RecordGift", request).GetBodyObject(GetType(recordGiftResponse), SoapServiceAttribute.TargetNamespace),recordGiftResponse)
  263.     End Function
  264.  
  265.     Public Function BeginRecordGift(  request As recordGiftRequest, callback As System.AsyncCallback, asyncState As Object) As IAsyncResult
  266.         Return MyBase.BeginSendRequestResponse("RecordGift", request, callback, asyncState)
  267.     End Function
  268.  
  269.     Public Function EndRecordGift( asyncResult As IAsyncResult ) As recordGiftResponse
  270.         Return CType(MyBase.EndSendRequestResponse(asyncResult).GetBodyObject(GetType(recordGiftResponse), SoapServiceAttribute.TargetNamespace),recordGiftResponse)
  271.     End Function
  272.  
  273. End Class
  274.  
May 13 '09 #1
0 6095

Sign in to post your reply or Sign up for a free account.

Similar topics

8
by: Piro | last post by:
I have a class that I want to make accessible to a web service. This class does some work in its constructor method and sets some class variables in its various methods. The problem I am having...
0
by: Daniel Thune, MCSE | last post by:
I am having a problem with formatting a SOAP Header in a .Net client. The client calls a Java Axis 1.1 based web service. In order to authenticate the caller, the web service call is intercepted by...
2
by: pshvarts | last post by:
(I'm new in SOAP) I get some wsdl file (from apache service ). I tried creating SOAP client with .NET - trying to add Web Reference and get error like: "Custom tool error: Unable to import...
0
by: Matt Wood | last post by:
Hi, I have written a Web Service for a customer which expects a SOAP message with Document/Literal encoding, and uses RoutingStyle=SoapServiceRoutingStyle.RequestElement to route the SOAP body...
0
by: info | last post by:
Dear all, is the first time that I use SOAP, and i must say that i'm having several problems. this is SOAP message that expects the server =================XML EXPECTED FROM THE...
0
by: Grzegorz Smith | last post by:
Hi All. I 'm learning ZSI to use SOAP and I desperately need help. I'm working on example from tutorial -(examples/server/send_response/ simple/wsdl/). Here are my wsdl files...
2
by: furrypop | last post by:
Hi, I'm trying to get the Perl SOAP::Lite examples to work on a Windows PC, running Apache 2.2.4. Apache is definitely serving CGI scripts, as I've tested a dummy Hello World thing. I'm also...
1
by: parimalb | last post by:
Hi All, I want to pass an array argument to the java webservice from perl client using SOAP::LITE package. Please let me know if anyone knows about this. The web method declaration in java is...
0
by: =?Utf-8?B?UlN1Yg==?= | last post by:
Hello, Hope I am asking this question in the right forum. We have been given a Wsdl file and the webservices link from a client. I am trying to invoke their web service first by creating a proxy...
4
by: gcharbon | last post by:
Hi community, I have a problem with a Soap client written in php. I have a local server (coded in c and a client in c too, it works fine), but i want to test client in php, and i have an error...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.