Results 1 to 11 of 11

Thread: Visual Basic & SOAP

  1. #1

    Thread Starter
    New Member
    Join Date
    Jul 2009
    Posts
    8

    Question Visual Basic & SOAP

    Hi Everyone,

    firstly thanks to everyone who has posted in the past i have used this forum many time.. I am first time poster however...

    My question is,

    I am trying to process a WSDL request using SOAP in Visual Basic (ACCESS).

    Two Question

    1) is it possible.
    2) how do i go about it.

    It also need authentication.

    Thanks in advance

    any help or sample code would be great.

    cheers
    alferr

  2. #2
    Super Moderator si_the_geek's Avatar
    Join Date
    Jul 2002
    Location
    Bristol, UK
    Posts
    41,530

    Re: Visual Basic & SOAP

    Thread moved to Office Development/VBA forum (note that the "VB Editor" in Office programs is actually VBA rather than VB, so the VB6 forum is not really apt)

  3. #3
    Superbly Moderated NeedSomeAnswers's Avatar
    Join Date
    Jun 2002
    Location
    Manchester uk
    Posts
    2,629

    Re: Visual Basic & SOAP

    I have done this in VB, so hopefully it's the same in Access.

    We had to use the MSSOAP30.dll (this comes with the "Microsoft Office Soap SDK version 3.0.0") library for some reason to get the SOAP requests to work in our app.

    Anyway here the code (assuming that you already have a web service setup.

    vb Code:
    1. Dim SoapClient As New SoapClient30
    2. Dim WebServerLocation As String
    3.  
    4. WebServerLocation = "You Web Server"
    5.  
    6. Set SoapClient = CreateObject("MSSOAP.SoapClient30")
    7.  
    8. SoapClient.MSSoapInit WebServerLocation & "?wsdl"
    9. SoapClient.ClientProperty("ServerHTTPRequest") = True
    10. SoapClient.ConnectorProperty("ConnectTimeout") = 30000
    11. SoapClient.ConnectorProperty("EndPointURL") = WebServerLocation

    You should then be able to execute the web service methods by writing - SoapClient.NameOfMethod
    Please Mark your Thread "Resolved", if the query is solved & Rate those who have helped you



  4. #4

    Thread Starter
    New Member
    Join Date
    Jul 2009
    Posts
    8

    Re: Visual Basic & SOAP

    HI Need Some Answers,

    Thanks for the post, seems to have got me closer then i was before.

    However when i execute i get "type mismatch" error on the line
    "Set SoapClient = CreateObject("MSSOAP.SoapClient30")"

    any suggestion on what i am doing wrong?

    I have added the DLL as a reference.

    the XML that gets submitted looks like this. how do i use Soapclient.NameofMethod to execute this i think the method is GetLedgerBalance.

    Code:
    <soap:Envelope xmlns:soap="http://www.w3.org/2003/05/soap-envelope" xmlns:ns="http://portal.voicestream.net.au/wsdl/1.4" xmlns:ns1="http://portal.voicestream.net.au/xsd/1.4">
       <soap:Header/>
       <soap:Body>
          <ns:GetLedgerBalance>
             <ledger_id>
                <ns1:ledger_id>1004264</ns1:ledger_id>
             </ledger_id>
          </ns:GetLedgerBalance>
       </soap:Body>
    </soap:Envelope>
    once again thank you for your help
    Last edited by alferr; Jul 27th, 2009 at 03:28 PM.

  5. #5
    PowerPoster
    Join Date
    Dec 2004
    Posts
    25,006

    Re: Visual Basic & SOAP

    make sure that your soap is version 3, otherwise try
    Set SoapClient = CreateObject("MSSOAP.SoapClient")
    Last edited by westconn1; Jul 27th, 2009 at 08:54 PM.
    i do my best to test code works before i post it, but sometimes am unable to do so for some reason, and usually say so if this is the case.
    Note code snippets posted are just that and do not include error handling that is required in real world applications, but avoid On Error Resume Next

    dim all variables as required as often i have done so elsewhere in my code but only posted the relevant part

    come back and mark your original post as resolved if your problem is fixed
    pete

  6. #6

    Thread Starter
    New Member
    Join Date
    Jul 2009
    Posts
    8

    Re: Visual Basic & SOAP

    Ok, excellent got rid of that error, it turns out, i had selected as reference MS SOAP Type Library 3.0 and also MS Office SOAP type Library 3.0, i deselected the MS office one and it worked..

    Ok now down to the nitty gritty..

    Trying to submit the above XML code, unsure what the next line to put in, is it something like this?

    Code:
    SoapClient.GetLedgerBalance ("ledger_id") = "1004264"
    and also how do i retrieve the result?

    Sorry for being such a newbie at this.

    regards
    alferr

  7. #7
    Superbly Moderated NeedSomeAnswers's Avatar
    Join Date
    Jun 2002
    Location
    Manchester uk
    Posts
    2,629

    Re: Visual Basic & SOAP

    Yes exactly,

    Here are examples of get and set methods.

    Get example -

    vb Code:
    1. dim Ledg_Id as String
    2. Ledg_Id  = SoapClient.GetLedgerBalance ("ledger_id")

    Set Example

    vb Code:
    1. dim Ledg_Id as String
    2.  
    3. Ledg_Id = "11111"
    4. SoapClient.GetLedgerBalance ("ledger_id") = Ledg_Id
    Please Mark your Thread "Resolved", if the query is solved & Rate those who have helped you



  8. #8

    Thread Starter
    New Member
    Join Date
    Jul 2009
    Posts
    8

    Re: Visual Basic & SOAP

    Thanks for the suggestion need,

    I tried the code

    vb Code:
    1. Dim Ledg_Id As String
    2. Ledg_Id = SoapClient.GetLedgerBalance("1004264")
    3. MsgBox (Ledg_Id)

    however i get the error.

    Run-time error '2147352571' (80020005):

    Client:Type Conversion Failure for element ledger_id
    Hresult=0x80020005:Type Mismatch.
    -Client:Unspecified client error. Hresult=0x80020005: Type Mismatch

    and it debugs to "Ledg_Id =" line.


    then instead i tried the set example:

    vb Code:
    1. Dim Ledg_Id As String
    2. Ledg_Id = "1004264"
    3. SoapClient.GetLedgerBalance("ledger_id") = Ledg_Id

    and i get the error:

    Runtime Error '446':

    Object doesn't support named arguments

    What do you suggest i am doing wrong, I have already programmed working PHP code to do the same thing this works fine and retrieves balance. posted below if it helps.


    Code:
    <?php
    	
    
    	// Do SOAP Request.
    	$client = new SoapClient(
           "https://esb.voicedot.net/services/VoicedotPortal?wsdl",
            array(  "login"      => "*****",
                    "password" => "******",
                 )
          );
    	// build arrays 2 arrays one inside the other, the sub array holds the ledger ID
    	$Ledger_ID = "1004264";
    	$subdetails = array("ledger_id" => $Ledger_ID);
    	$details = array("ledger_id" => $subdetails);
    	
    	//submit request
    	$response = $client->GetLedgerBalance($details);
    	
    	// display request
    	echo "<pre>";
    	echo $response->balance->elements->balance;
    	echo "</pre>";
    ?>
    have blanked our username and password.

    I think we are almost there any suggestions on the next step?

    Thanks again

  9. #9
    Superbly Moderated NeedSomeAnswers's Avatar
    Join Date
    Jun 2002
    Location
    Manchester uk
    Posts
    2,629

    Re: Visual Basic & SOAP

    Should you be using writing the Get command like this -

    vb Code:
    1. Dim Ledg_Id As String
    2. Ledg_Id = SoapClient.GetLedgerBalance("ledger_Id")
    3. MsgBox (Ledg_Id)

    Then your return value would be - 1004264
    Please Mark your Thread "Resolved", if the query is solved & Rate those who have helped you



  10. #10

    Thread Starter
    New Member
    Join Date
    Jul 2009
    Posts
    8

    Re: Visual Basic & SOAP

    Thanks need,

    my apologies i didn't explain it properly, by sending the value of the ledger id, the server will return the balance.

    ie. send the server ledger_id value of 1004264, and it should return with the balance of that account.

    re

  11. #11
    Superbly Moderated NeedSomeAnswers's Avatar
    Join Date
    Jun 2002
    Location
    Manchester uk
    Posts
    2,629

    Re: Visual Basic & SOAP

    Hi again,

    sorry but i am not sure. When i have done this using VB, we had an ASP.Net application which had an Configuration.asmx page which i queried. The page looked nothing like your Soap Envelope above.

    Basically the .asmx page had a couple of methods on it GetLoginDetails & SetLoginDetails
    which looked like this -

    vb Code:
    1. public string GetLoginDetails()
    2.         {
    3.             return ConfigurationManager.AppSettings.Get("LoginDetails");
    4.         }

    maybe this might help - http://www.developerfusion.com/article/24/xml-soap/5/
    Please Mark your Thread "Resolved", if the query is solved & Rate those who have helped you



Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width