; English forum: http://www.purebasic.fr/english/viewtopic.php?t=13436&highlight= ; Author: Leo ; Date: 20. December 2004 ; OS: Windows ; Demo: No ; Using COM and SOAP to get temperature at XMethods ; ************************************************* ; To promote the use of ActiveX and of Axend's InterfaceGenerator, I post here ; a small example how to use the pocketSOAP component that can be downloaded ; from http://www.pocketsoap.com/ The example retrieves the temperature from ; the http://services.xmethods.net:80/soap/servlet/rpcrouter site ; ; For some reason the ComLib of Axend does not work with CreateObject ; ("pocketSOAP.HTTPTransport.2") (it crashes), so I used the CoCreateInstanceEx ; instead. ; ; The actual program (need the generated Interface pSoap32.pb) XIncludeFile "pSoap32.pb" Result.l = CoCreateInstance_(?CLSID_CoEnvelope,0,1,?IID_ISOAPEnvelope,@oEnvelope.ISOAPEnvelope) ;oEnvelope.ISOAPEnvelope = CreateObject("pocketSOAP.Envelope.2") Result=oEnvelope\SetMethod ( Ansi2Uni("getTemp"), Ansi2Uni("urn:xmethods-Temperature")) pNodes.l Result=oEnvelope\get_Parameters(@pNodes) zip.VARIANT zip\vt = #VT_BSTR zip\bstrVal = Ansi2Uni("94107") *zip.pToVariant=zip *oNodes.ISOAPNodes=pNodes Result=*oNodes\Create(Ansi2Uni(""),*zip\a,*zip\b,*zip\c,*zip\d,0,0,0,0) Result=*oNodes\Release() Result.l =CoInitialize_(0) Result.l = CoCreateInstance_(?CLSID_HTTPTransport,0,1,?IID_IHTTPTransport,@oHTTP.IHTTPTransport) ;oHTTP.IHTTPTransport = CreateObject("pocketSOAP.HTTPTransport.2") Result=oHTTP\put_SOAPAction(Ansi2Uni("")) Envelope=AllocateMemory(5000) Result=oEnvelope\Serialize(@Envelope) Result=oHTTP\Send ( Ansi2Uni("http://services.xmethods.net:80/soap/servlet/rpcrouter"), Envelope ) voHTTP.VARIANT voHTTP\vt = #VT_UNKNOWN voHTTP\value=oHTTP *voHTTP.pToVariant = voHTTP oEnvelope\Parse(*voHTTP\a, *voHTTP\b, *voHTTP\c, *voHTTP\d, Ansi2Uni("")) oNodes.l Result=oEnvelope\get_Parameters(@oNodes) *oNodes.ISOAPNodes=oNodes oNode.l Result=*oNodes\get_Item(0, @oNode) *oNode.ISOAPNode=oNode v.VARIANT *v.pToVariant = v *oNode\get_Value(@v) BSTR.VARIANT Result=VariantChangeType_(@BSTR,@V,0,#VT_BSTR) h.f=48.0 MessageRequester("Temperature in Fahrenheit",Uni2Ansi(BSTR\value),0) DataSection CLSID_HTTPTransport: Data.l $D76BA06F Data.w $ABF3,$4c1f Data.b $BD,$C9,$18,$48,$D4,$E3,$CF,$2B EndDataSection DataSection IID_IHTTPTransport: Data.l $C2F39358 Data.w $2B60,$4FDA Data.b $B6,$FC,$E9,$5D,$CC,$4E,$9C,$9B EndDataSection DataSection CLSID_CoEnvelope: Data.l $e2e0fb24 Data.w $e58f,$458f Data.b $84,$e0,$6e,$09,$d2,$d5,$15,$11 EndDataSection DataSection IID_ISOAPEnvelope: Data.l $8b2091b1 Data.w $dcf9,$44a7 Data.b $a5,$0b,$f0,$29,$71,$a0,$1b,$f1 EndDataSection ; IDE Options = PureBasic v4.02 (Windows - x86) ; Folding = -