Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 6 of 6
  1. #1
    Senior Coder
    Join Date
    Dec 2002
    Location
    Arlington, Texas USA
    Posts
    1,072
    Thanks
    4
    Thanked 8 Times in 8 Posts

    Problem with XMLHTTP

    I am consuming an XML web service for one of my clients. In using the web service I first make initial contact and get a response. Then depending on the services ordered by the client new calls are made utilizing other methods. This all works great until I get to one of the methods which is not giving me a response. I am running the code in a for loop at this point and calling this particular sub as often as needed. I cannot figure out why I am not getting a response whenever I try to send some data in this call. This led me to believe it is not even sending so I added the following test to check and it shows that it is not sending.
    Code:
    If myXMLHTTP.Send(SOAPRequest)  Then
                Response.Write "It Sent <br />"
    Else
                Response.Write "It did not send<br />"
    End If

    I also tried to see if I recieved a 200 response using the code below, No go there either
    Code:
    If myXMLHTTP.Status = 200 Then
    	Response.Write "It sent<br />"
    Else
    	Response.Write "It did not send<br />"
    End If
    Here is part of the code that is running in the loop. For brevity I will only show one of the cases as there are a number of possibilities
    Code:
    Select Case Trim(Services(i))
    	Case "DDS_00114" ' Canadian Abstract
    		orderFieldsXML = ""
    		orderFieldsXML = orderFieldsXML & "<OrderField NewOrderID=""1"" FieldID=""38555"" value=""CAN"" />" 		'country
    		orderFieldsXML = orderFieldsXML & "<OrderField NewOrderID=""1"" FieldID=""38556"" value=""" & DLState & """ />" 	'Province
    		orderFieldsXML = orderFieldsXML & "<OrderField NewOrderID=""1"" FieldID=""38557"" value=""" & DLNumber & """ />"	'Driver's License
    		orderFieldsXML = orderFieldsXML & "<OrderField NewOrderID=""1"" FieldID=""38558"" value=""" & Sex(Gender) & """ />"	'Gender
    		Call AddClearStarOrder(UserName, Password, BusinessOwnerID, CustomerID, ProfileNumber, Trim(Services(i)),orderFieldsXML)
    Here is the routine I am calling
    Code:
    Sub AddClearStarOrder(UserName, Password, BusinessOwnerID, CustomerID, ProfileNumber, ServiceNumber, orderFieldsXML)
    	' Set myXMLHTTP = Server.CreateObject("Microsoft.XMLHTTP")
    	Set myXMLHTTP = Server.CreateObject("MSXML2.ServerXMLHTTP")
    	myXMLHTTP.Open "POST", "https://gateway.clearstar.net/CSGWprofile/profile.asmx", false
    	myXMLHTTP.setRequestHeader "Content-Type", "text/xml; charset=utf-8" 
    	myXMLHTTP.setRequestHeader "SOAPAction", "http://clearstar.net/Gateway/Profile/AddOrderToProfile" 
    	SOAPRequest = "<?xml version=""1.0"" encoding=""utf-8""?>"
    	SOAPRequest = SOAPRequest & "<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/"">"
    	SOAPRequest = SOAPRequest & "<soap:Body>"
    	SOAPRequest = SOAPRequest & "<AddOrderToProfile xmlns=""http://clearstar.net/Gateway/Profile"">"
    	SOAPRequest = SOAPRequest & "<sUserName>" & UserName & "</sUserName>"
    	SOAPRequest = SOAPRequest & "<sPassword>" & Password & "</sPassword>"
    	SOAPRequest = SOAPRequest & "<iBOID>" & BusinessOwnerID & "</iBOID>"
    	SOAPRequest = SOAPRequest & "<sCustID>" & CustomerID & "</sCustID>"
    	SOAPRequest = SOAPRequest & "<sProfNo>" & ProfileNumber & "</sProfNo>"
    	SOAPRequest = SOAPRequest & "<sServiceNo>" & ServiceNumber & "</sServiceNo>"
    	SOAPRequest = SOAPRequest & "<sCountry>USA</sCountry>"
    	SOAPRequest = SOAPRequest & "<sState>" & CurrentState  & "</sState>"
    	SOAPRequest = SOAPRequest & "<sCounty>" & ProperXML(CurrentCounty)  & "</sCounty>"
    	SOAPRequest = SOAPRequest & "<sCity>" & ProperXML(CurrentCity) & "</sCity>"
    	SOAPRequest = SOAPRequest & "<sZip />"
    	SOAPRequest = SOAPRequest & "<sInstruct />"
    	SOAPRequest = SOAPRequest & "<sStage />"
    	SOAPRequest = SOAPRequest & "<iAliasID>0</iAliasID>"
    	SOAPRequest = SOAPRequest & "<sOrderFieldsXML>" 
    	SOAPRequest = SOAPRequest & "<OrderFields>" & orderFieldsXML & "</OrderFields>"
    	SOAPRequest = SOAPRequest & "</sOrderFieldsXML>"
    	SOAPRequest = SOAPRequest & "</AddOrderToProfile>"
    	SOAPRequest = SOAPRequest & " </soap:Body>"
    	SOAPRequest = SOAPRequest & " </soap:Envelope>"
    	myXMLHTTP.Send(SOAPRequest) 
    	
    	responseXML = myXMLHTTP.ResponseXML.XML
    	Set myXMLHTTP = Nothing
    	Response.Write SOAPRequest & "<br />" & vbCrLF & vbCrLF
    	Response.Write "Response:<br />" & responseXML & "<br /><br /><br />" & vbCrLF & vbCrLF
    End Sub
    The response.Write on the SOAPRequest string does show the data whereas the Response.Write on the responseXML string shows zip

    When I wrote the code a month or so ago everything was working great. Then yesterday as I am going over the software with the cleint showing them how to use it, it doesn't work. I am at a loss as to what to try next.
    Last edited by miranda; 12-14-2011 at 06:00 PM.

  • #2
    Supreme Master coder! Old Pedant's Avatar
    Join Date
    Feb 2009
    Posts
    27,650
    Thanks
    80
    Thanked 4,638 Times in 4,600 Posts
    Could you maybe try seeing if responseText contains anything meaningful?

    And you are checking for 200 responsestatus, but how about just dumping it out, whatever it is?

    I do see that you aren't using Server.URLEncode consistently for your values. Are you positive that you don't have some character in there that is illegal XML?

    I admit to grasping at straws here.

    You may have no choice but to contact the owner of the Web Service for help. Maybe they could diagnose what you are sending?
    An optimist sees the glass as half full.
    A pessimist sees the glass as half empty.
    A realist drinks it no matter how much there is.

  • Users who have thanked Old Pedant for this post:

    miranda (12-14-2011)

  • #3
    Supreme Master coder! Old Pedant's Avatar
    Join Date
    Feb 2009
    Posts
    27,650
    Thanks
    80
    Thanked 4,638 Times in 4,600 Posts
    (And I'll bet you wish you were using ASP.NET for this. I work on a site that was all ASP, but just because I wanted to work with a web service, I created some ASP.NET pages to do so and then invoked them from the ASP code.)
    An optimist sees the glass as half full.
    A pessimist sees the glass as half empty.
    A realist drinks it no matter how much there is.

  • #4
    Senior Coder
    Join Date
    Dec 2002
    Location
    Arlington, Texas USA
    Posts
    1,072
    Thanks
    4
    Thanked 8 Times in 8 Posts
    Thank you. It was the ResponseStatus which returned a 400

    I knew there was something simple I was missing now it is just a matter of time waiting for Clearstar to contact me back.

    Instead of using Server.URLEncode I have a function that does that for me when needed


    I have stayed away from the .Net part because on one of our servers it was never turned on. Even though we have it turned on with the newer servers I never get time to hone the .Net skills

    One thing I always have problems with is the sql server connections. We use system dsns and have integrated windows authentication that does not use the IUSR account

    BTW are you the poster from the ASPmessageboard with initials BW?

  • #5
    Supreme Master coder! Old Pedant's Avatar
    Join Date
    Feb 2009
    Posts
    27,650
    Thanks
    80
    Thanked 4,638 Times in 4,600 Posts
    Yes, Bill Wilkinson. I don't mind the association. I've cross-reference my postings before.

    ********

    I saw your function that apparently was doing the encoding, but there were are few places you aren't using it that I would have thought you would need to, just in case.
    For example:
    Code:
    SOAPRequest = SOAPRequest & "<sUserName>" & UserName & "</sUserName>"
    Can you be sure that a UserName doesn't include (for example) an ampersand?

    ***********

    Not to ask a silly question...but why use DSNs? Company policy?
    An optimist sees the glass as half full.
    A pessimist sees the glass as half empty.
    A realist drinks it no matter how much there is.

  • #6
    Senior Coder
    Join Date
    Dec 2002
    Location
    Arlington, Texas USA
    Posts
    1,072
    Thanks
    4
    Thanked 8 Times in 8 Posts
    Yes I know those fields cannot have any illegal characters ie ampersand, apostrophe, quotation marks etc..

    the 1st 3 fields may always remain the same. These distinguish our client from other Clearstar clients. Our client uses the Clearstar service to run their background checks but Clearstar actually has a number of different services that use their web services.

    Our client in turn provides our AMS to employers that need an ams as well as background checking service. It may always only be the 4th item that always changes for the different employers but i figure why hard code it in and take a chance, So when they set up each employer I prefer they save the data for all fields just in case.

    Yes company policy The only time I was able to change this was the very few instances that access was used for something, and right now there are only 5 instances of access being used. I would prefer no access databases.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •