|
web
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
XmlHttp can access webservices from javascript, but not from within applications?After creating an end-point with batches enabled using SQL Server 2005, I can easily query a database and have xml returned from within javascript using something like Pablo's code (below). But, if I try the same code from VB6 or VB.NET (a straight forward port - swap ActiveXObject for CreateObject, remove ';'s etc) I always get 'Incorrect Parameter' on the send method of xmlhttp. Why should it work from script but not applications, could it be that the request headers need to be different or are somehow 'more correct' when issued from within an ecma environment? Many thanks, Duncan. ---Javascript sample: http://weblogs.asp.net/cibrax/archive/2005/04/22/403868.aspx--- function SendBatchRequest( strServerName, strUrlPath, strQuery ) { var objXmlHttp = null; var strRequest = ""; objXmlHttp = new ActiveXObject( "microsoft.xmlhttp" ); objXmlHttp.open( "POST", "http://" + strServerName + strUrlPath, false ); objXmlHttp.setrequestheader( "Content-Type", "text/xml" ); objXmlHttp.setRequestHeader( "Host", strServerName ); strRequest = "<SOAP-ENV:Envelope xmlns:SOAP-ENV='http://schemas.xmlsoap.org/soap/envelope/' xmlns:sql='http://schemas.microsoft.com/sqlserver/2004/SOAP'> <SOAP-ENV:Body> <sql:sqlbatch> <sql:BatchCommands>" + strQuery + "</sql:BatchCommands> </sql:sqlbatch> </SOAP-ENV:Body> </SOAP-ENV:Envelope>"; objXmlHttp.send( strRequest ); if( objXmlHttp.status == 200 ) return objXmlHttp.responseXML.xml; else return ""; } var response = SendBatchRequest( 'localhost', '/sql/myendpoint', 'Select * from sys.http_endpoints' ); ------ Could you provide the VB repro that does not work?
<DSmith1***@googlemail.com> wrote in message Show quoteHide quote news:1142432954.874060.277290@j33g2000cwa.googlegroups.com... > Hi All, > > After creating an end-point with batches enabled using SQL Server 2005, > I can easily query a database and have xml returned from within > javascript using something like Pablo's code (below). > > But, if I try the same code from VB6 or VB.NET (a straight forward port > - swap ActiveXObject for CreateObject, remove ';'s etc) I always get > 'Incorrect Parameter' on the send method of xmlhttp. > > Why should it work from script but not applications, could it be that > the request headers need to be different or are somehow 'more correct' > when issued from within an ecma environment? > > Many thanks, > > Duncan. > > ---Javascript sample: > http://weblogs.asp.net/cibrax/archive/2005/04/22/403868.aspx--- > function SendBatchRequest( strServerName, strUrlPath, strQuery ) > { > var objXmlHttp = null; > var strRequest = ""; > > objXmlHttp = new ActiveXObject( "microsoft.xmlhttp" ); > objXmlHttp.open( "POST", "http://" + strServerName + strUrlPath, > false ); > objXmlHttp.setrequestheader( "Content-Type", "text/xml" ); > objXmlHttp.setRequestHeader( "Host", strServerName ); > > strRequest = "<SOAP-ENV:Envelope > > xmlns:SOAP-ENV='http://schemas.xmlsoap.org/soap/envelope/' > > xmlns:sql='http://schemas.microsoft.com/sqlserver/2004/SOAP'> > <SOAP-ENV:Body> > <sql:sqlbatch> > <sql:BatchCommands>" + strQuery + > "</sql:BatchCommands> > </sql:sqlbatch> > </SOAP-ENV:Body> > </SOAP-ENV:Envelope>"; > > objXmlHttp.send( strRequest ); > > if( objXmlHttp.status == 200 ) > return objXmlHttp.responseXML.xml; > else > return ""; > } > > var response = SendBatchRequest( 'localhost', '/sql/myendpoint', > 'Select * from sys.http_endpoints' ); > ------ >
Open a Text File in Notepad using VB.Net 2005
[Help] Reading data from a DLL structure in C Playing System Sounds/WAV files Where is ThisWorkbook.Sheets("xx") ?? Unable to resolve 'ThisWorkbook' :: Interop to Excel Datetime arithmetic in VB.Net? KeyDown event bindingsource running balance in datagrid what should i use? Different ways to go about storing data in an xml file.. |
|||||||||||||||||||||||