[Webinar] Streamline your web hosting managementRegister Today

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 468
  • Last Modified:

Eliminate Html form and use VB

I have an external program, written with a proprietary language that will populate Global Variables. I would like to eliminate the form shown below and use Visual Basic to GET the global variables, produce the SOAP object, and send it.

So instead of using the html form to manually enter the data, I would like to eliminate the html form and use VB to GET the Global Variables from the third party program and produce the SOAP object, and send it.

Here is the code:
*****************************************************************

<html>

   

  <head>

    <link rel="alternate" type="text/xml" href="clientservices.asmx?disco"/>

    <style type="text/css">
   
          BODY { color: #000000; background-color: white; font-family: Verdana; margin-left: 0px; margin-top: 0px; }
          #content { margin-left: 30px; font-size: .70em; padding-bottom: 2em; }
          A:link { color: #336699; font-weight: bold; text-decoration: underline; }
          A:visited { color: #6699cc; font-weight: bold; text-decoration: underline; }
          A:active { color: #336699; font-weight: bold; text-decoration: underline; }
          A:hover { color: cc3300; font-weight: bold; text-decoration: underline; }
          P { color: #000000; margin-top: 0px; margin-bottom: 12px; font-family: Verdana; }
          pre { background-color: #e5e5cc; padding: 5px; font-family: Courier New; font-size: x-small; margin-top: -5px; border: 1px #f0f0e0 solid; }
          td { color: #000000; font-family: Verdana; font-size: .7em; }
          h2 { font-size: 1.5em; font-weight: bold; margin-top: 25px; margin-bottom: 10px; border-top: 1px solid #003366; margin-left: -15px; color: #003366; }
          h3 { font-size: 1.1em; color: #000000; margin-left: -15px; margin-top: 10px; margin-bottom: 10px; }
          ul { margin-top: 10px; margin-left: 20px; }
          ol { margin-top: 10px; margin-left: 20px; }
          li { margin-top: 10px; color: #000000; }
          font.value { color: darkblue; font: bold; }
          font.key { color: darkgreen; font: bold; }
          .heading1 { color: #ffffff; font-family: Tahoma; font-size: 26px; font-weight: normal; background-color: #003366; margin-top: 0px; margin-bottom: 0px; margin-left: -30px; padding-top: 10px; padding-bottom: 3px; padding-left: 15px; width: 105%; }
          .button { background-color: #dcdcdc; font-family: Verdana; font-size: 1em; border-top: #cccccc 1px solid; border-bottom: #666666 1px solid; border-left: #cccccc 1px solid; border-right: #666666 1px solid; }
          .frmheader { color: #000000; background: #dcdcdc; font-family: Verdana; font-size: .7em; font-weight: normal; border-bottom: 1px solid #dcdcdc; padding-top: 2px; padding-bottom: 2px; }
          .frmtext { font-family: Verdana; font-size: .7em; margin-top: 8px; margin-bottom: 0px; margin-left: 32px; }
          .frmInput { font-family: Verdana; font-size: 1em; }
          .intro { margin-left: -15px; }
           
    </style>

    <title>ClientServices Web Service</title>

  </head>

  <body>

    <div id="content">

      <p class="heading1">ClientServices</p><br>

     

     

      <span>
          <p class="intro">Click <a href="clientservices.asmx">here</a> for a complete list of operations.</p>
          <h2>CheckForexTrade</h2>
          <p class="intro">Test a Forex Trade (Admin Only)</p>

          <h3>Test</h3>
         
          To test the operation using the HTTP POST protocol, click the 'Invoke' button.



                      <form target="_blank" action='http://10.0.3.109/clientservices.asmx/CheckForexTrade' method="POST">                      
                       
                          <table cellspacing="0" cellpadding="4" frame="box" bordercolor="#dcdcdc" rules="none" style="border-collapse: collapse;">
                          <tr>
     <td class="frmHeader" background="#dcdcdc" style="border-right: 2px solid white;">Parameter</td>
     <td class="frmHeader" background="#dcdcdc">Value</td>
</tr>

                       
                          <tr>
                            <td class="frmText" style="color: #000000; font-weight: normal;">sLoginId:</td>
                            <td><input class="frmInput" type="text" size="50" name="sLoginId"></td>
                          </tr>
                       
                          <tr>
                            <td class="frmText" style="color: #000000; font-weight: normal;">sPassword:</td>
                            <td><input class="frmInput" type="text" size="50" name="sPassword"></td>
                          </tr>
                       
                          <tr>
                            <td class="frmText" style="color: #000000; font-weight: normal;">sManagedByAccount:</td>
                            <td><input class="frmInput" type="text" size="50" name="sManagedByAccount"></td>
                          </tr>
                       
                          <tr>
                            <td class="frmText" style="color: #000000; font-weight: normal;">sAccountNumber:</td>
                            <td><input class="frmInput" type="text" size="50" name="sAccountNumber"></td>
                          </tr>
                       
                          <tr>
                            <td class="frmText" style="color: #000000; font-weight: normal;">BuySell:</td>
                            <td><input class="frmInput" type="text" size="50" name="BuySell"></td>
                          </tr>
                       
                          <tr>
                            <td class="frmText" style="color: #000000; font-weight: normal;">CurrencyItem:</td>
                            <td><input class="frmInput" type="text" size="50" name="CurrencyItem"></td>
                          </tr>
                       
                          <tr>
                            <td class="frmText" style="color: #000000; font-weight: normal;">sOrderType:</td>
                            <td><input class="frmInput" type="text" size="50" name="sOrderType"></td>
                          </tr>
                       
                          <tr>
                            <td class="frmText" style="color: #000000; font-weight: normal;">sPrice:</td>
                            <td><input class="frmInput" type="text" size="50" name="sPrice"></td>
                          </tr>
                       
                          <tr>
                            <td class="frmText" style="color: #000000; font-weight: normal;">Quantity:</td>
                            <td><input class="frmInput" type="text" size="50" name="Quantity"></td>
                          </tr>
                       
                          <tr>
                            <td class="frmText" style="color: #000000; font-weight: normal;">MiniForex:</td>
                            <td><input class="frmInput" type="text" size="50" name="MiniForex"></td>
                          </tr>
                       
                        <tr>
                          <td></td>
                          <td align="right"> <input type="submit" value="Invoke" class="button"></td>
                        </tr>
                        </table>
                     

                    </form>
                  <span>
              <h3>SOAP</h3>
              <p>The following is a sample SOAP request and response.  The <font class=value>placeholders</font> shown need to be replaced with actual values.</p>

              <pre>POST /clientservices.asmx HTTP/1.1
Host: 10.0.3.109
Content-Type: text/xml; charset=utf-8
Content-Length: <font class=value>length</font>
SOAPAction: "http://www.forexdealer.com/CheckForexTrade"

&lt;?xml version="1.0" encoding="utf-8"?&gt;
&lt;soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"&gt;
  &lt;soap:Body&gt;
    &lt;CheckForexTrade xmlns="http://www.forexdealer.com"&gt;
      &lt;sLoginId&gt;<font class=value>string</font>&lt;/sLoginId&gt;
      &lt;sPassword&gt;<font class=value>string</font>&lt;/sPassword&gt;
      &lt;sManagedByAccount&gt;<font class=value>string</font>&lt;/sManagedByAccount&gt;
      &lt;sAccountNumber&gt;<font class=value>string</font>&lt;/sAccountNumber&gt;
      &lt;BuySell&gt;<font class=value>string</font>&lt;/BuySell&gt;
      &lt;CurrencyItem&gt;<font class=value>string</font>&lt;/CurrencyItem&gt;
      &lt;sOrderType&gt;<font class=value>string</font>&lt;/sOrderType&gt;
      &lt;sPrice&gt;<font class=value>string</font>&lt;/sPrice&gt;
      &lt;Quantity&gt;<font class=value>string</font>&lt;/Quantity&gt;
      &lt;MiniForex&gt;<font class=value>string</font>&lt;/MiniForex&gt;
    &lt;/CheckForexTrade&gt;
  &lt;/soap:Body&gt;
&lt;/soap:Envelope&gt;</pre>

              <pre>HTTP/1.1 200 OK
Content-Type: text/xml; charset=utf-8
Content-Length: <font class=value>length</font>

&lt;?xml version="1.0" encoding="utf-8"?&gt;
&lt;soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"&gt;
  &lt;soap:Body&gt;
    &lt;CheckForexTradeResponse xmlns="http://www.forexdealer.com"&gt;
      &lt;CheckForexTradeResult&gt;<font class=value>string</font>&lt;/CheckForexTradeResult&gt;
    &lt;/CheckForexTradeResponse&gt;
  &lt;/soap:Body&gt;
&lt;/soap:Envelope&gt;</pre>
          </span>

          <span>
              <h3>HTTP GET</h3>
              <p>The following is a sample HTTP GET request and response.  The <font class=value>placeholders</font> shown need to be replaced with actual values.</p>

              <pre>GET /clientservices.asmx/CheckForexTrade?<font class=key>sLoginId</font>=<font class=value>string</font>&amp;<font class=key>sPassword</font>=<font class=value>string</font>&amp;<font class=key>sManagedByAccount</font>=<font class=value>string</font>&amp;<font class=key>sAccountNumber</font>=<font class=value>string</font>&amp;<font class=key>BuySell</font>=<font class=value>string</font>&amp;<font class=key>CurrencyItem</font>=<font class=value>string</font>&amp;<font class=key>sOrderType</font>=<font class=value>string</font>&amp;<font class=key>sPrice</font>=<font class=value>string</font>&amp;<font class=key>Quantity</font>=<font class=value>string</font>&amp;<font class=key>MiniForex</font>=<font class=value>string</font> HTTP/1.1
Host: 10.0.3.109
</pre>

              <pre>HTTP/1.1 200 OK
Content-Type: text/xml; charset=utf-8
Content-Length: <font class=value>length</font>

&lt;?xml version="1.0" encoding="utf-8"?&gt;
&lt;string xmlns="http://www.forexdealer.com"&gt;<font class=value>string</font>&lt;/string&gt;</pre>
          </span>

          <span>
              <h3>HTTP POST</h3>
              <p>The following is a sample HTTP POST request and response.  The <font class=value>placeholders</font> shown need to be replaced with actual values.</p>

              <pre>POST /clientservices.asmx/CheckForexTrade HTTP/1.1
Host: 10.0.3.109
Content-Type: application/x-www-form-urlencoded
Content-Length: <font class=value>length</font>

<font class=key>sLoginId</font>=<font class=value>string</font>&amp;<font class=key>sPassword</font>=<font class=value>string</font>&amp;<font class=key>sManagedByAccount</font>=<font class=value>string</font>&amp;<font class=key>sAccountNumber</font>=<font class=value>string</font>&amp;<font class=key>BuySell</font>=<font class=value>string</font>&amp;<font class=key>CurrencyItem</font>=<font class=value>string</font>&amp;<font class=key>sOrderType</font>=<font class=value>string</font>&amp;<font class=key>sPrice</font>=<font class=value>string</font>&amp;<font class=key>Quantity</font>=<font class=value>string</font>&amp;<font class=key>MiniForex</font>=<font class=value>string</font></pre>

              <pre>HTTP/1.1 200 OK
Content-Type: text/xml; charset=utf-8
Content-Length: <font class=value>length</font>

&lt;?xml version="1.0" encoding="utf-8"?&gt;
&lt;string xmlns="http://www.forexdealer.com"&gt;<font class=value>string</font>&lt;/string&gt;</pre>
          </span>

      </span>
     

     


  </body>
</html>
*****************************************************************
0
MrWizard2u2
Asked:
MrWizard2u2
  • 4
  • 4
1 Solution
 
eyeh8uCommented:
I'm a little confused by exactly what you are trying to do, but basicaly it looks like you want to call a SOAP service from Visual Basic? This is actualy really easy to do, you need the Microsoft SOAP toolkit v3 whcih you can download from their web site. Then you do

Set objSoap = New MSSOAPLib30.SoapClient30
objSOAP.MSSoapInit "http://www.someserver.com/soapurl"

This then creates methods on the objSoap object for each SOAP service offered by that url, so if they have a "Checkforextade" method you then do:

result = objSoap.Checkforextrade(arg1, arg2, arg3)

If the result is a simple type, such as a string or integer or something, you can just read it. If it's more complex, then it will be a bit of XML, which you can load and parse with the MSXSL.DomDocument.4.0 object to find the fields you are after:

Set objXML = new MSXML.DomDocument.4.0
objXML.loadXML( result )

What you do with it after that is up to you.

I'm not quite sure where your global variables come from, could you clarify what is going on there?
0
 
eyeh8uCommented:
Bit more of a look and:
<CheckForexTrade xmlns="http://www.forexdealer.com">
      <sLoginId>string</sLoginId>
      <sPassword>string</sPassword>
      <sManagedByAccount>string</sManagedByAccount>
      <sAccountNumber>string</sAccountNumber>
      <BuySell>string</BuySell>
      <CurrencyItem>string</CurrencyItem>
      <sOrderType>string</sOrderType>
      <sPrice>string</sPrice>
      <Quantity>string</Quantity>
      <MiniForex>string</MiniForex>
</CheckForexTrade> is the method with those arguments, so:

strResult = objSoap.CheckForexTrade (sLoginId, sPassword, sManagedByAccount, sAccountNumber, BuySell, CurrencyItem, sOrderType, sPrice, Quantity, MiniForex)

And you just get a simple string response. Now, I don't know where you get the values to send in the arguments from, you say you "use VB to GET the Global Variables from the third party program" I don't have enough information to show you how to do that in VB.
0
 
MrWizard2u2Author Commented:
Thanks eyeh8u for your quick response and your patience. The above example is extreamly helpful. I posted below the method I intend to use to "Get" the Global Variables. The Global Variables are actually generated by another program written in TradeStations EasyLanguage. A DLL is inserted into the EasyLanguage code that will allow the use of Global Variables. I want to use VB to "Get" or "Read" the Global Variables and execute the XML/Soap code shown in my first Experts Exchange entry.

The only line of code that I really think that I will need to "Read" the Global Variables would be the " sLoginId = ReadFloatValue ("MysLoginId")" along with the other ReadFloatValue functions shown below.

The entire read process should be triggered by an "IF sTrigger=1 THEN" type statment. After I "Read" the Global Variables I would like to automatically Invoke/Submit the above XML/Soap code (written in VB) without a button press or any manual execution.

I hope the code below makes sense. I am new to VB, XML, and Soap.

Public Declare Function ReadFloatValue Lib "dots5.dll" Alias "READFLOATVALUE" (ByVal sName As String) As Single

Dim sTrigger As Single, sLoginId As Single, sPassword As Single, sManagedByAccount As Single, _
       sAccountNumber As Single, BuySell As Single, sCurrencyItem As Single, _
       sOrderType As Single, sPrice As Single, sQuantity As Single, MiniForex As Single
sTrigger= 1
sLoginId=LShaw
sPassword=abcxyz
sManagedByAccount=11111
sAccountNumber=12345
BuySell=1
CurrencyItem=EUR
sOrderType=1
sPrice=0
Quantity=200000
MiniForex=0

WriteFloatValue "MysTrigger", sTrigger
WriteFloatValue "MysLoginId", sLoginId
WriteFloatValue "MysPassword", sPassword
...etc

sTrigger = ReadFloatValue ("MysTrigger")
sLoginId = ReadFloatValue ("MysLoginId")
sPassword = ReadFloatValue ("MysPassword")

0
Never miss a deadline with monday.com

The revolutionary project management tool is here!   Plan visually with a single glance and make sure your projects get done.

 
eyeh8uCommented:
Something like the following in your class file, the sub doCall() will have strResult containing the response in a /local/ variable. I don't know what you want to do with it, so I leave that to you. Something would have to call LoadVariables. An event, a button press. Formload whatever. A timer. BUt there you go.



Public Declare Function ReadFloatValue Lib "dots5.dll" Alias "READFLOATVALUE" (ByVal sName As String) As Single

Dim sTrigger As Single, sLoginId As Single, sPassword As Single, sManagedByAccount As Single, _
       sAccountNumber As Single, BuySell As Single, sCurrencyItem As Single, _
       sOrderType As Single, sPrice As Single, sQuantity As Single, MiniForex As Single

Private Sub doCall()
Dim objSoap as MSSOAPLib30.soapclient30
Dim strResult as String

Set objSoap = New MSSOAPLib30.SoapClient30
objSOAP.MSSoapInit "http://www.someserver.com/soapurl"

strResult = objSoap.CheckForexTrade (sLoginId, sPassword, sManagedByAccount, sAccountNumber, BuySell, CurrencyItem, sOrderType, sPrice, Quantity, MiniForex)

End Sub

Private Sub LoadVariables()
sTrigger= 1
sLoginId=LShaw
sPassword=abcxyz
sManagedByAccount=11111
sAccountNumber=12345
BuySell=1
CurrencyItem=EUR
sOrderType=1
sPrice=0
Quantity=200000
MiniForex=0

WriteFloatValue "MysTrigger", sTrigger
WriteFloatValue "MysLoginId", sLoginId
WriteFloatValue "MysPassword", sPassword
...etc

sTrigger = ReadFloatValue ("MysTrigger")
sLoginId = ReadFloatValue ("MysLoginId")
sPassword = ReadFloatValue ("MysPassword")

' If we have the value we need, trigger the call to soap:
If sTrigger = 1 Then
  Call doCall()
End If

End Sub
0
 
MrWizard2u2Author Commented:
I've listed the code that I've been using below. Upon execution, I get a Run-time Error '-2147024809 (80070057)' WSDLReader:XML Parser failed. The system cannot locate the resource specified.

I dont understand what to place at your example url: objSOAP.MSSoapInit "http://www.someserver.com/soapurl"

If necessary, please reference the original soap/xml code shown in my very first post.

Here is the code I've typed so far.
'**********************************************
'**********************************************
Public Declare Function ReadFloatValue Lib "dots5.dll" Alias "READFLOATVALUE" (ByVal sName As String) As Single


Private Sub Main()
Dim sTrigger As Single, sLoginId As Single, sPassword As Single, sManagedByAccount As Single, _
       sAccountNumber As Single, BuySell As Single, CurrencyItem As Single, _
       sOrderType As Single, sPrice As Single, Quantity As Single, MiniForex As Single

Call LoadVariables



End Sub

Private Sub doCall()
Dim objSoap As MSSOAPLib30.SoapClient30
'Dim objSoap As MSSOAP.SoapClient30
'Dim objSoap As MSSOAP.MSSoap30
Dim strResult As String

'Set objSoap = CreateObject("MSSOAP.SoapClient30")
Set objSoap = New MSSOAPLib30.SoapClient30
'objSoap.MSSoapInit "http://www.someserver.com/soapurl"
'objSoap.MSSoapInit "http://www.forexdealer.com/CheckForexTrade"
objSoap.MSSoapInit "http://10.0.3.109/clientservices.asmx"

strResult = objSoap.CheckForexTrade(sLoginId, sPassword, sManagedByAccount, sAccountNumber, BuySell, CurrencyItem, sOrderType, sPrice, Quantity, MiniForex)

End Sub

Private Sub LoadVariables()

'sTrigger = ReadFloatValue("MyTrigger")
sTrigger = 1
sLoginId = lawrence
sPassword = shaw
sManagedByAccount = 0
sAccountNumber = 21204
'BuySell = ReadFloatValue("MyBuySell")
BuySell = 2
'CurrencyItem = ReadFloatValue("MyCurrencyItem")  'Could be EUR
CurrencyItem = EUR
sOrderType = 1
sPrice = 0
'Quantity = ReadFloatValue("MyQuantity")   'Could be 10000
Quantity = 100000
MiniForex = 0

' If we have the value we need, trigger the call to soap:
If sTrigger = 1 Then
  Call doCall
End If

End Sub
'**********************************************
'**********************************************


0
 
eyeh8uCommented:
The WSDL file is found here:
http://www.forexdealer.com/clientservices.asmx?WSDL

So you do

objsoap.mssoapinit "http://www.forexdealer.com/clientservices.asmx?WSDL"

The url:
http://www.forexdealer.com/clientservices.asmx

Provides a human readable list of API's available and provides a link to the actual WSDL file.
0
 
MrWizard2u2Author Commented:
Thank you for your suggestion. I made the change and successfully got passed the "objsoap" error only to encounter a new error. Any examples of a fix would be greatly appreciated.

Question: Will I need to switch to the method that you suggested earlier:
    Set objXML = new MSXML.DomDocument.4.0
    objXML.loadXML( result )

or

given the original code that I recently posted above, is it possible to run the code using:
   Set objSoap = New MSSOAPLib30.SoapClient30
   objSoap.MSSoapInit "http://www.forexdealer.com/clientservices.asmx?WSDL"

...and have it return data displayed in a format similar to the the format displayed as a result of running the original code shown in my 1st post.

                  *****************************************************

I receive the error message shown below when I try to run "strResult = ....."

  Set objSoap = New MSSOAPLib30.SoapClient30
  objSoap.MSSoapInit "http://www.forexdealer.com/clientservices.asmx?WSDL"

strResult = objSoap.CheckForexTrade(sLoginId, sPassword, sManagedByAccount, sAccountNumber, BuySell, CurrencyItem, sOrderType, sPrice, Quantity, MiniForex)

           Run-time error '-2147024809 (80070057)':

           SoapMapper:Restoring data into SoapMapper CheckForexTradeResult
           failed HRESULT=0x80070057: The parameter is incorrect.
           -Client:Unspecified client error. HRESULT=0x80070057: The parameter is incorrect.



0
 
MrWizard2u2Author Commented:
eyeh8u,

Thanks for your help. The  line of code: "objSoap.MSSoapInit "http://www.forexdealer.com/clientservices.asmx?WSDL""

was correct except that I need to use an internal IP address for the domain name vs.  "www.forexdealer.com".

Again thanks. Your suggestions saved me hours of research and training.

0
 
moduloCommented:
Closed, 500 points refunded.

modulo
Community Support Moderator
Experts Exchange
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 4
  • 4
Tackle projects and never again get stuck behind a technical roadblock.
Join Now