Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Soap, web services
Message
De
04/09/2008 10:47:16
Jay Johengen
Altamahaw-Ossipee, Caroline du Nord, États-Unis
 
 
À
06/08/2008 03:00:39
Information générale
Forum:
Visual FoxPro
Catégorie:
Web Services
Versions des environnements
Visual FoxPro:
VFP 9 SP2
OS:
Vista
Divers
Thread ID:
01336781
Message ID:
01344819
Vues:
42
>Hi all,
>
>i need to work with soap and webservices but know nothing about these things.
>
>My task is to make an application thats makes a connection and retrive information via a webservice.
>
>Does somebody know a site that explanes step by step how to work with these things or how to make a connection to a webservice and retrive the information ?
>
>thnx.


I worked long and hard on exactly that recently. Here is some code blocks that I pulled out so you could get an idea of one way to do it. This
will not work for you as is, it is just pieces of code so you get the idea.
* Create Objects

	_SCREEN.ADDPROPERTY("oXML")
	_SCREEN.oXML = CREATEOBJECT("Microsoft.XMLHTTP")
	_SCREEN.ADDPROPERTY("oXMLDoc")
	_SCREEN.oXMLDoc = CREATEOBJECT('msxml.domdocument')

* Setup Authenticaton Variables

	* Concantenated User Name and Password
	cBuffer = lcUserName + ':' + lcPassword

	* Base64 Encoding
	cEncoded = STRCONV(cBuffer,13)
	* cDecoded = STRCONV(cEncoded,14)

	* Define Authentication String
	cAuthenticate = "Basic " + cEncoded


* SubmitRequest

	TextRequestMessage = 'The actual message sent to the server goes here.'

	* Build the submitRealtimeRequestXML manually. The TextRequestMessage variable is inserted into this XML.
	TEXT TO submitRealtimeRequestHeader NOSHOW PRETEXT 7
	<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
	 <soapenv:Body>
	  <ns1:submitRealtimeRequest soapenv:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" xmlns:ns1="urn:realtime">
	   <request xsi:type="xsd:string">
	ENDTEXT

	TEXT TO submitRealtimeRequestFooter NOSHOW PRETEXT 7
	</request>
	  </ns1:submitRealtimeRequest>
	 </soapenv:Body>
	</soapenv:Envelope>
	ENDTEXT

	* Create the XML message manually and save it for debugging
	submitRealtimeRequestXML = submitRealtimeRequestHeader + TextRequestMessage + submitRealtimeRequestFooter
	* STRTOFILE(submitRealtimeRequestXML,"c:\temp\submitRealtimeRequestXML.txt")

	* Open POST
	_SCREEN.oXML.OPEN("POST", lcURL, .F.)

	* Set Headers
	_SCREEN.oXML.setRequestHeader("Content-Type","application/x-www-form-urlencoded")
	_SCREEN.oXML.setRequestHeader("SOAPAction", "''")
	_SCREEN.oXML.setRequestHeader("authorization", cAuthenticate)

	TRY
		_SCREEN.oXML.SEND(submitRealtimeRequestXML)
		submitRealtimeRequestMessage = _SCREEN.oXML.ResponseText

	CATCH TO oCatch
		TSHIdentifier = ''
	ENDTRY

	IF TYPE('oCatch') <> 'O'
		X12Message = ConvertXML('Request',submitRealtimeRequestMessage)
		TSHIdentifier = X12Message
		RETURN .T.
	ELSE
		RETURN .F.
	ENDIF


* Pull Response

	* Build the pullRealtimeResponseXML manually. The TextRequestMessage variable is inserted into this XML.
	TEXT TO pullRealtimeResponseHeader NOSHOW PRETEXT 7
	<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
	 <soapenv:Body>
	  <ns1:pullRealtimeResponse soapenv:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" xmlns:ns1="urn:realtime">
	   <request xsi:type="xsd:string">
	ENDTEXT

	TEXT TO pullRealtimeResponseFooter NOSHOW PRETEXT 7
	</request>
	  </ns1:pullRealtimeResponse>
	 </soapenv:Body>
	</soapenv:Envelope>
	ENDTEXT

	* Create the XML message manually and save it for debugging
	pullRealtimeResponseXML = pullRealtimeResponseHeader + TSHIdentifier + pullRealtimeResponseFooter
	* STRTOFILE(pullRealtimeResponseXML,"c:\temp\pullRealtimeResponseXML.txt")

	* Open POST
	_SCREEN.oXML.OPEN("POST", lcURL, .F.)

	* Set Headers
	_SCREEN.oXML.setRequestHeader("Content-Type","application/x-www-form-urlencoded")
	_SCREEN.oXML.setRequestHeader("SOAPAction", "''")
	_SCREEN.oXML.setRequestHeader("authorization", cAuthenticate)

	_SCREEN.oXML.SEND(pullRealtimeResponseXML)
	pullRealtimeResponseMessage = _SCREEN.oXML.ResponseText
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform