Alpha Software Mobile Development Tools:   Alpha Anywhere    |   Alpha TransForm subscribe to our YouTube Channel  Follow Us on LinkedIn  Follow Us on Twitter  Follow Us on Facebook

Announcement

Collapse

The Alpha Software Forum Participation Guidelines

The Alpha Software Forum is a free forum created for Alpha Software Developer Community to ask for help, exchange ideas, and share solutions. Alpha Software strives to create an environment where all members of the community can feel safe to participate. In order to ensure the Alpha Software Forum is a place where all feel welcome, forum participants are expected to behave as follows:
  • Be professional in your conduct
  • Be kind to others
  • Be constructive when giving feedback
  • Be open to new ideas and suggestions
  • Stay on topic


Be sure all comments and threads you post are respectful. Posts that contain any of the following content will be considered a violation of your agreement as a member of the Alpha Software Forum Community and will be moderated:
  • Spam.
  • Vulgar language.
  • Quotes from private conversations without permission, including pricing and other sales related discussions.
  • Personal attacks, insults, or subtle put-downs.
  • Harassment, bullying, threatening, mocking, shaming, or deriding anyone.
  • Sexist, racist, homophobic, transphobic, ableist, or otherwise discriminatory jokes and language.
  • Sexually explicit or violent material, links, or language.
  • Pirated, hacked, or copyright-infringing material.
  • Encouraging of others to engage in the above behaviors.


If a thread or post is found to contain any of the content outlined above, a moderator may choose to take one of the following actions:
  • Remove the Post or Thread - the content is removed from the forum.
  • Place the User in Moderation - all posts and new threads must be approved by a moderator before they are posted.
  • Temporarily Ban the User - user is banned from forum for a period of time.
  • Permanently Ban the User - user is permanently banned from the forum.


Moderators may also rename posts and threads if they are too generic or do not property reflect the content.

Moderators may move threads if they have been posted in the incorrect forum.

Threads/Posts questioning specific moderator decisions or actions (such as "why was a user banned?") are not allowed and will be removed.

The owners of Alpha Software Corporation (Forum Owner) reserve the right to remove, edit, move, or close any thread for any reason; or ban any forum member without notice, reason, or explanation.

Community members are encouraged to click the "Report Post" icon in the lower left of a given post if they feel the post is in violation of the rules. This will alert the Moderators to take a look.

Alpha Software Corporation may amend the guidelines from time to time and may also vary the procedures it sets out where appropriate in a particular case. Your agreement to comply with the guidelines will be deemed agreement to any changes to it.



Bonus TIPS for Successful Posting

Try a Search First
It is highly recommended that a Search be done on your topic before posting, as many questions have been answered in prior posts. As with any search engine, the shorter the search term, the more "hits" will be returned, but the more specific the search term is, the greater the relevance of those "hits". Searching for "table" might well return every message on the board while "tablesum" would greatly restrict the number of messages returned.

When you do post
First, make sure you are posting your question in the correct forum. For example, if you post an issue regarding Desktop applications on the Mobile & Browser Applications board , not only will your question not be seen by the appropriate audience, it may also be removed or relocated.

The more detail you provide about your problem or question, the more likely someone is to understand your request and be able to help. A sample database with a minimum of records (and its support files, zipped together) will make it much easier to diagnose issues with your application. Screen shots of error messages are especially helpful.

When explaining how to reproduce your problem, please be as detailed as possible. Describe every step, click-by-click and keypress-by-keypress. Otherwise when others try to duplicate your problem, they may do something slightly different and end up with different results.

A note about attachments
You may only attach one file to each message. Attachment file size is limited to 2MB. If you need to include several files, you may do so by zipping them into a single archive.

If you forgot to attach your files to your post, please do NOT create a new thread. Instead, reply to your original message and attach the file there.

When attaching screen shots, it is best to attach an image file (.BMP, .JPG, .GIF, .PNG, etc.) or a zip file of several images, as opposed to a Word document containing the screen shots. Because Word documents are prone to viruses, many message board users will not open your Word file, therefore limiting their ability to help you.

Similarly, if you are uploading a zipped archive, you should simply create a .ZIP file and not a self-extracting .EXE as many users will not run your EXE file.
See more
See less

Help needed setting up http_fetch

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    Help needed setting up http_fetch

    Hey all,

    I'm trying to wrap my head around getting this to work. I need to make some calls to an API and get the response. It does not need to have ssl active The credentials in the code are live test credentials and will provide a response. I'm not sure if I am putting the right stuff in the right place. After weeks of reading every post I can find on the forum about the http functions I think the code Steve has up will do the trick if I can modify it correctly.

    The test service is located here for documentation purposes http://wsd.adminscreen.net/evolution...CostPriceBySKU
    The service can be called directly from a browser http://wsd.adminscreen.net/evolution.asmx/ViewCostPriceBySKU?ServerID=1&TokenKey=42274449465b2c744c7461645649666c7c4865747a6b7a282f433d797d&Password=test1&SkuID=unv21200

    Once I get the request down I'll start working on what to do with it. I plan on setting it in fields to save to a database table.

    HTML Code:
    <%a5
    dim req	 as p
    dim req.body	 as c = ""
    dim req.header	 as c = ""
    dim req.host	 as c = "wsd.adminscreen.net"
    dim req.method	 as c = "POST"
    dim req.page	 as c = "/ViewCostPriceBySKU"
    dim req.ssl_on	 as l = .f.
    dim req.ssl_validatecert	as l = .f.
    dim req.timeout	 as n = 10000
    dim resp	 as p
    
    req.header = <<%a%
    text/xml; charset=utf-8 %a%
    
    req.body = <<%xml%
    <?xml version="1.0" encoding="utf-8"?>
    <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/">
    <soap:Body>
    <ViewCostPriceBySKU xmlns="http://wsd.adminscreen.net">
    <ServerID>1</ServerID>
    <TokenKey>42274449465b2c744c7461645649666c7c4865747a6b7a282f433d797d</TokenKey>
    <Password>test1</Password>
    <SkuID>unv21200</SkuID>
    </ViewCostPriceBySKU>
    </soap:Body>
    </soap:Envelope>
    %xml%
    
    resp = http_fetch(Req)
    
    Any assistance is appreciated
    Last edited by DDPMarc; 05-14-2014, 10:29 AM. Reason: fix code
    Thanks,

    Marc McCall

    Version 12.3 2128 -4292
    MySQL backend

    If at first you don�t succeed, call it version 1.0

    #2
    Re: Help needed setting up http_fetch

    Your req.page does not appear to be accurate. The URL is http://wsd.adminscreen.net/evolution...CostPriceBySKU, so:

    req.host = "wsd.adminscreen.net"
    req.page = "/evolution.asmx"
    req.query_string = "op=ViewCostPriceBySKU"
    Steve Wood
    See my profile on IADN

    Comment


      #3
      Re: Help needed setting up http_fetch

      Steve, thanks for the reply.

      It is my understanding that the url http://wsd.adminscreen.net/evolution...CostPriceBySKU is just for testing as it is a page with a form the actual page that gives a response is http://wsd.adminscreen.net/evolution...CostPriceBySKU with the added parameters in the URL. I may be wrong, but I thought the form page is just a place to enter the request data to send to the request page for manual testing.
      Thanks,

      Marc McCall

      Version 12.3 2128 -4292
      MySQL backend

      If at first you don�t succeed, call it version 1.0

      Comment


        #4
        Re: Help needed setting up http_fetch

        I did notice this though, I was missing http://wsd.adminscreen.net/evolution.asmx/ in the url.
        Thanks,

        Marc McCall

        Version 12.3 2128 -4292
        MySQL backend

        If at first you don�t succeed, call it version 1.0

        Comment


          #5
          Re: Help needed setting up http_fetch

          Ok, well I'v tried your suggestion Steve, but I'm still getting the same results.

          HTML Code:
          <%a5
          dim req	 as p
          req.body = ""
          req.header = ""
          req.host = "wsd.adminscreen.net"
          req.method = "POST"
          req.page = "/evolution.asmx"
          req.query_string = "op=ViewCostPriceBySKU"
          req.ssl_on as l = .f.
          req.ssl_validatecert as l = .f.
          req.timeout as n = 10000
          resp as p
          
          req.header = <<%a%
          text/xml; charset=utf-8 %a%
          
          req.body = <<%xml%
          <?xml version="1.0" encoding="utf-8"?>
          <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/">
          <soap:Body>
          <ViewCostPriceBySKU xmlns="http://wsd.adminscreen.net">
          <ServerID>1</ServerID>
          <TokenKey>42274449465b2c744c7461645649666c7c4865747a6b7a282f433d797d</TokenKey>
          <Password>test1</Password>
          <SkuID>unv21200</SkuID>
          </ViewCostPriceBySKU>
          </soap:Body>
          </soap:Envelope>
          %xml%
          
          resp = http_fetch(req)
          This give me

          HTML Code:
          ?resp
          = body = 
          error_code = 1
          error_text = "Host must be specified."
          headers = ""
          +parsed_headers.
          
          ?req
          = body = ""
          cookie = ""
          header = ""
          host = ""
          method = ""
          page = "/evolution.asmx"
          port = 0
          protocol = ""
          query_string = ""
          referer = ""
          ssl_on = .F.
          ssl_ValidateCert = .T.
          timeout = 0
          user_agent = ""
          I don't understand why it would have a "Host must be specified." error since I have one.
          Thanks,

          Marc McCall

          Version 12.3 2128 -4292
          MySQL backend

          If at first you don�t succeed, call it version 1.0

          Comment


            #6
            Re: Help needed setting up http_fetch

            Well this is very strange, but I couldn't get http_get to work earlier with the exact same code, but now it is working and giving me a response in the interactive window.

            HTML Code:
            dim response as p
            dim url as c
            
            url = "http://wsd.adminscreen.net/evolution.asmx/ViewCostPriceBySKU?ServerID=1&TokenKey=42274449465b2c744c7461645649666c7c4865747a6b7a282f433d797d&Password=test1&SkuID=unv21200"
            
            response = http_get(url)
            ?response.body
            = <?xml version="1.0" encoding="utf-8"?>
            <DataSet xmlns="http://wsd.adminscreen.net">
              <xs:schema id="NewDataSet" xmlns="" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
                <xs:element name="NewDataSet" msdata:IsDataSet="true" msdata:UseCurrentLocale="true">
                  <xs:complexType>
                    <xs:choice minOccurs="0" maxOccurs="unbounded">
                      <xs:element name="ViewCostPriceBySKU">
                        <xs:complexType>
                          <xs:sequence>
                            <xs:element name="idcostprice" type="xs:int" minOccurs="0" />
                            <xs:element name="idproduct" type="xs:int" minOccurs="0" />
                            <xs:element name="sku" type="xs:string" minOccurs="0" />
                            <xs:element name="cost" type="xs:double" minOccurs="0" />
                            <xs:element name="date_added" type="xs:dateTime" minOccurs="0" />
                            <xs:element name="external_id" type="xs:string" minOccurs="0" />
                            <xs:element name="idsupplier" type="xs:int" minOccurs="0" />
                          </xs:sequence>
                        </xs:complexType>
                      </xs:element>
                    </xs:choice>
                  </xs:complexType>
                </xs:element>
              </xs:schema>
              <diffgr:diffgram xmlns:msdata="urn:schemas-microsoft-com:xml-msdata" xmlns:diffgr="urn:schemas-microsoft-com:xml-diffgram-v1">
                <NewDataSet xmlns="">
                  <ViewCostPriceBySKU diffgr:id="ViewCostPriceBySKU1" msdata:rowOrder="0">
                    <idcostprice>37214208</idcostprice>
                    <idproduct>9877</idproduct>
                    <sku>UNV21200</sku>
                    <cost>168.32</cost>
                    <date_added>2013-07-16T11:23:27-05:00</date_added>
                    <idsupplier>1</idsupplier>
                  </ViewCostPriceBySKU>
                </NewDataSet>
              </diffgr:diffgram>
            </DataSet>
            So I think I will use this instead of fetch, and need to figure out how to parse the xml response and load it into the database.
            Thanks,

            Marc McCall

            Version 12.3 2128 -4292
            MySQL backend

            If at first you don�t succeed, call it version 1.0

            Comment


              #7
              Re: Help needed setting up http_fetch

              Your page, query_string and header values are incorrect, and your XML body is missing a closing tag. The following should work as expected.

              Code:
              req.body = ""
              req.header = ""
              req.host = "wsd.adminscreen.net"
              req.method = "POST"
              [COLOR="#FF0000"]req.page = "/evolution.asmx/ViewCostPriceBySKU"
              req.query_string = ""[/COLOR]
              req.ssl_on as l = .f.
              req.ssl_validatecert as l = .f.
              req.timeout as n = 10000
              [COLOR="#FF0000"]dim[/COLOR] resp as p
              
              [COLOR="#FF0000"]req.header = "Content-Type: text/xml"[/COLOR]
              
              
              req.body = <<%xml%
              #<?xml version="1.0" encoding="utf-8"?>
              #<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/">
              <soap:Body>
              <ViewCostPriceBySKU xmlns="http://wsd.adminscreen.net">
              <ServerID>1</ServerID>
              <TokenKey>42274449465b2c744c7461645649666c7c4865747a6b7a282f433d797d</TokenKey>
              <Password>test1</Password>
              <SkuID>unv21200</SkuID>
              </ViewCostPriceBySKU>
              </soap:Body>
              </soap:Envelope>
              [COLOR="#FF0000"]</xml>[/COLOR]
              %xml%
              
              resp = http_fetch(req)

              Lenny Forziati
              Vice President, Internet Products and Technical Services
              Alpha Software Corporation

              Comment


                #8
                Re: Help needed setting up http_fetch

                Lenny thanks for the input, I may look back into fetch later but I'm getting good results now from get so I'll just stick with that.

                Now if I can just figure out why pasting code into the interactive window won't run correctly.
                Thanks,

                Marc McCall

                Version 12.3 2128 -4292
                MySQL backend

                If at first you don�t succeed, call it version 1.0

                Comment


                  #9
                  Re: Help needed setting up http_fetch

                  So I have the code getting responses now and i'm re coding this to work with API function I really want to use but I'm having difficulty getting the current record data into variables to use in the url variable.

                  This worked for me in the last function i was helped in putting together, but now its not recognizing the function I'm trying to use to get the data from the current record. Not sure why it work in one function and not another.

                  I'm trying to use e._currentRowDataNew.FieldName to get the current field data from the current record.


                  HTML Code:
                  function addEvoCustomer as c (e as p)
                  	
                  	debug(1)
                  	dim response as p
                  	
                  	dim id_customer as c
                  	
                  	'web service address and credential variables
                  	dim address as c
                  	dim opperation as c
                  	dim server_id as c
                  	dim tokenKey as c
                  	dim ws_password as c
                  	
                  	'AddCustomer Values variables
                  	dim User_CustomerTypeID as c
                  	dim User_FullName as c
                  	dim User_CompanyName as c
                  	dim User_Telephone as c
                  	dim User_Email as c
                  	dim User_Password as c
                  	dim Internal_Account as c
                  	dim External_ID as c
                  	
                  	dim customer_id as n
                  	
                  	'url variable
                  	dim url as c
                  	
                  	
                  	'Values to add Customer
                  	address = "wsd.adminscreen.net"
                  	opperation = "/evolution.asmx/AddCustomer?"
                  	server_id = "ServerID=1"
                  	tokenKey = "&TokenKey=42274449465b2c744c7461645649666c7c4865747a6b7a282f433d797d"
                  	ws_password = "&Password=test1"
                  	
                  	
                  	User_CustomerTypeID ="&User_CustomerTypeID="
                  	User_FullName ="&User_FullName="
                  	User_CompanyName ="&User_CompanyName="
                  	User_Telephone ="&User_Telephone="
                  	User_Email ="&User_Email="
                  	User_Password ="&User_Password="
                  	Internal_Account ="&Internal_Account="
                  	External_ID ="&External_ID="
                  	
                  	User_CustomerTypeID = User_CustomerTypeID+e._currentRowDataNew.Customer_Type
                  	User_FullName = User_FullName+e._currentRowDataNew.First_Name+e._currentRowDataNew.First_Name
                  	User_CompanyName = User_CompanyName+e._currentRowDataNew.Account
                  	User_Telephone = User_Telephone+e._currentRowDataNew.Phone1
                  	User_Email = User_Email+e._currentRowDataNew.Email
                  	User_Password = User_Password+e._currentRowDataNew.Password
                  	Internal_Account = Internal_Account+e._currentRowDataNew.Dove_Account
                  	External_ID = External_ID+e._currentRowDataNew.Dove_Account
                  	
                  	
                  	
                  	customer_id = e._currentRowDataNew.Customer_ID
                  	id_customer = +e._currentRowDataNew.EVO_Customer_ID
                  	
                  	response.body as c = ""
                  	
                  	url = address+opperation+server_id+tokenKey+ws_password+User_CustomerTypeID+User_FullName+User_CompanyName+User_Telephone+User_Email+User_Password+Internal_Account+External_ID
                  	
                  	if 	id_customer > 0
                  		addEvoCustomer = "alert ('This Customer has already been added to EVO')"
                  	else
                  		response = http_get(url)
                  		
                  		if .not. eval_valid("response.body")
                  			ui_msg_box("Error","The function did not work",UI_STOP_SYMBOL)
                  		else
                  			
                  			responce.body = extract_string(response.body,"<idcustomer>","</idcustomer>",1,.f.)
                  			'===============================================
                  			dim cn as sql::Connection
                  			dim result as l
                  			
                  			result = cn.Open("::Name::evo_utility_db_connection") 'connect to database with named connection
                  			if result then
                  				
                  				dim sqlUpdate as c
                  				sqlUpdate = "UPDATE customers SET EVO_Customer_ID = (:NewID) WHERE Customer_ID = (:NewCustomer_ID)" 'update customer with new group_accounts group_id in the id_goup field
                  				args.add("NewID",response.body)
                  				args.add("NewCustomer_ID",customer_id)
                  				result = cn.Execute(sqlUpdate,args)
                  				if result then
                  					
                  					addEvoCustomer = "alert('Your Customer was added to EVO!');"
                  					e._set.EVO_Customer_ID.value = response.body
                  				else
                  					addEvoCustomer = "alert('Could not add Customer to EVO!');"
                  				end if
                  				
                  				
                  				cn.close()
                  			else
                  				addEvoCustomer = "alert('Could not connect to database!');"
                  				
                  			end if
                  		end if
                  	end if
                  	
                  	
                  	
                  end function

                  Thanks again for any assistance.
                  Last edited by DDPMarc; 05-15-2014, 03:03 PM.
                  Thanks,

                  Marc McCall

                  Version 12.3 2128 -4292
                  MySQL backend

                  If at first you don�t succeed, call it version 1.0

                  Comment


                    #10
                    Re: Help needed setting up http_fetch

                    Figured it out. There is a little check box with "Compute current row data"
                    Thanks,

                    Marc McCall

                    Version 12.3 2128 -4292
                    MySQL backend

                    If at first you don�t succeed, call it version 1.0

                    Comment

                    Working...
                    X