EDN Admin
Well-known member
Hello,
I am having difficulty invoking a Web Service from a VBScript Application.
I created a Web Service with Visual Studio 2010 and have tested this independently after publishing it to my web site. It works fine.
However, when I attempt to invoke it with the code below the XMLHTTP.Send returns a status of 500
<br/>
and the following Error Message in the response:
"System.InvalidOperationException: Request format is invalid: <br/>
Application/soap+xml; charset=utf-8.at System.Web.Services.Protocols.HttpServerProtocol.ReadParameters() at System.Web.Service...
I have pasted the service description into the code as comments.
Any suggestions that I can use to fix this will be greatly appreciated. Thank you in advance.
Regards,
Matt Paisley<br/>
New Haven, CT
*** Code Sample ***
<br/>
Private Sub ValidationForm_ButtonClicked(ByVal ButtonName As String, ByVal pXDoc As CASCADELib.CscXDocument)
**************************************************************************<br/>
*** Service Description
***<br/>
*** The SoapEnvelope for the Post is stored in a Script Resource ***<br/>
*** This is fetched with the line: ***<br/>
*** strSoapEnvelope = Project.Resources.StringByKey("SoapEnvelope") ***<br/>
**************************************************************************<br/>
POST /Travelers/Service.asmx HTTP/1.1<br/>
Host: localhost<br/>
Content-Type: Application/soap+xml; charset=utf-8<br/>
Content-Length: length
<?xml version="1.0" encoding="utf-8"?><br/>
<soap12:Envelope xmlns:xsi=" http://www.w3.org/2001/XMLSchema-instance http://www.w3.org/2001/XMLSchema-instance " xmlns:xsd=" http://www.w3.org/2001/XMLSchema http://www.w3.org/2001/XMLSchema " xmlns:soap12=" http://www.w3.org/2003/05/soap-envelope http://www.w3.org/2003/05/soap-envelope <br/>
<soap12:Body><br/>
<GetChoicesFromProperty xmlns=" http://tempuri.org/ http://tempuri.org/ <br/>
<ObjectStore>ANY</ObjectStore><br/>
<DocClass>PUT_PROPERTY_HERE</DocClass><br/>
</GetChoicesFromProperty><br/>
</soap12:Body><br/>
</soap12:Envelope>
HTTP/1.1 200 OK<br/>
Content-Type: Application/soap+xml; charset=utf-8<br/>
Content-Length: length
<?xml version="1.0" encoding="utf-8"?><br/>
<soap12:Envelope xmlns:xsi=" http://www.w3.org/2001/XMLSchema-instance http://www.w3.org/2001/XMLSchema-instance " xmlns:xsd=" http://www.w3.org/2001/XMLSchema http://www.w3.org/2001/XMLSchema " xmlns:soap12=" http://www.w3.org/2003/05/soap-envelope http://www.w3.org/2003/05/soap-envelope <br/>
<soap12:Body><br/>
<GetChoicesFromPropertyResponse xmlns=" http://tempuri.org/ http://tempuri.org/ <br/>
<GetChoicesFromPropertyResult><br/>
<String>String</String><br/>
<String>String</String><br/>
</GetChoicesFromPropertyResult><br/>
</GetChoicesFromPropertyResponse><br/>
</soap12:Body><br/>
</soap12:Envelope>
Dim oXMLHTTP As New XMLHTTP<br/>
Dim oXMLDoc As New DOMDocument<br/>
Dim strSoapEnvelope As String<br/>
Dim strURL As String<br/>
Dim strProp As String
*** Get DocClass Property from form<br/>
strProp = pXDoc.Fields.ItemByName("DocClass").Text
*** Fetch SOAP Envelope from Script Resource and replace DocClass property
<br/>
strSoapEnvelope = Project.Resources.StringByKey("SoapEnvelope")<br/>
strSoapEnvelope = Replace(strSoapEnvelope, "PUT_PROPERTY_HERE",strProp ,1)
strURL = " http://localhost/Travelers/Service.asmx/GetChoicesFromProperty http://localhost/Travelers/Service.asmx/GetChoicesFromProperty "
oXMLHTTP.Open("POST", strURL, False)<br/>
oXMLHTTP.setRequestHeader("Host", "localhost")<br/>
oXMLHTTP.setRequestHeader("Content-Type", "tapplication/x-www-form-urlencoded; charset=utf-8")
oXMLHTTP.send(strSoapEnvelope)
MsgBox(oXMLHTTP.responseText)
End Sub <hr class="sig Matthew Paisley
View the full article
I am having difficulty invoking a Web Service from a VBScript Application.
I created a Web Service with Visual Studio 2010 and have tested this independently after publishing it to my web site. It works fine.
However, when I attempt to invoke it with the code below the XMLHTTP.Send returns a status of 500
<br/>
and the following Error Message in the response:
"System.InvalidOperationException: Request format is invalid: <br/>
Application/soap+xml; charset=utf-8.at System.Web.Services.Protocols.HttpServerProtocol.ReadParameters() at System.Web.Service...
I have pasted the service description into the code as comments.
Any suggestions that I can use to fix this will be greatly appreciated. Thank you in advance.
Regards,
Matt Paisley<br/>
New Haven, CT
*** Code Sample ***
<br/>
Private Sub ValidationForm_ButtonClicked(ByVal ButtonName As String, ByVal pXDoc As CASCADELib.CscXDocument)
**************************************************************************<br/>
*** Service Description
***<br/>
*** The SoapEnvelope for the Post is stored in a Script Resource ***<br/>
*** This is fetched with the line: ***<br/>
*** strSoapEnvelope = Project.Resources.StringByKey("SoapEnvelope") ***<br/>
**************************************************************************<br/>
POST /Travelers/Service.asmx HTTP/1.1<br/>
Host: localhost<br/>
Content-Type: Application/soap+xml; charset=utf-8<br/>
Content-Length: length
<?xml version="1.0" encoding="utf-8"?><br/>
<soap12:Envelope xmlns:xsi=" http://www.w3.org/2001/XMLSchema-instance http://www.w3.org/2001/XMLSchema-instance " xmlns:xsd=" http://www.w3.org/2001/XMLSchema http://www.w3.org/2001/XMLSchema " xmlns:soap12=" http://www.w3.org/2003/05/soap-envelope http://www.w3.org/2003/05/soap-envelope <br/>
<soap12:Body><br/>
<GetChoicesFromProperty xmlns=" http://tempuri.org/ http://tempuri.org/ <br/>
<ObjectStore>ANY</ObjectStore><br/>
<DocClass>PUT_PROPERTY_HERE</DocClass><br/>
</GetChoicesFromProperty><br/>
</soap12:Body><br/>
</soap12:Envelope>
HTTP/1.1 200 OK<br/>
Content-Type: Application/soap+xml; charset=utf-8<br/>
Content-Length: length
<?xml version="1.0" encoding="utf-8"?><br/>
<soap12:Envelope xmlns:xsi=" http://www.w3.org/2001/XMLSchema-instance http://www.w3.org/2001/XMLSchema-instance " xmlns:xsd=" http://www.w3.org/2001/XMLSchema http://www.w3.org/2001/XMLSchema " xmlns:soap12=" http://www.w3.org/2003/05/soap-envelope http://www.w3.org/2003/05/soap-envelope <br/>
<soap12:Body><br/>
<GetChoicesFromPropertyResponse xmlns=" http://tempuri.org/ http://tempuri.org/ <br/>
<GetChoicesFromPropertyResult><br/>
<String>String</String><br/>
<String>String</String><br/>
</GetChoicesFromPropertyResult><br/>
</GetChoicesFromPropertyResponse><br/>
</soap12:Body><br/>
</soap12:Envelope>
Dim oXMLHTTP As New XMLHTTP<br/>
Dim oXMLDoc As New DOMDocument<br/>
Dim strSoapEnvelope As String<br/>
Dim strURL As String<br/>
Dim strProp As String
*** Get DocClass Property from form<br/>
strProp = pXDoc.Fields.ItemByName("DocClass").Text
*** Fetch SOAP Envelope from Script Resource and replace DocClass property
<br/>
strSoapEnvelope = Project.Resources.StringByKey("SoapEnvelope")<br/>
strSoapEnvelope = Replace(strSoapEnvelope, "PUT_PROPERTY_HERE",strProp ,1)
strURL = " http://localhost/Travelers/Service.asmx/GetChoicesFromProperty http://localhost/Travelers/Service.asmx/GetChoicesFromProperty "
oXMLHTTP.Open("POST", strURL, False)<br/>
oXMLHTTP.setRequestHeader("Host", "localhost")<br/>
oXMLHTTP.setRequestHeader("Content-Type", "tapplication/x-www-form-urlencoded; charset=utf-8")
oXMLHTTP.send(strSoapEnvelope)
MsgBox(oXMLHTTP.responseText)
End Sub <hr class="sig Matthew Paisley
View the full article