Solved

webservice different node levels

Posted on 2013-05-27
3
259 Views
Last Modified: 2013-05-28
I am trying to connect to a web service using asp post
 Set objHTTP =  CreateObject("WinHttp.WinHttpRequest.5.1")
vPostData = "op=ValidateTinName&TIN=" & request.form("taxid") & "&LName="  & request.form("Name") & "&UserLogin=*****g&UserPassword=***#"
objHTTP.Open "POST", "https://www.****", false
objHTTP.Send  vPostData
response.write(objHTTP.ResponseText)

Open in new window

I am getting an error " Data at the root level is invalid."
The page is asking for xml is different levels. How would I change my postdata to represent that.
 <ValidateTinName xmlns="******">
      <TinName>
        <TIN>string</TIN>
        <LName>string</LName>
        <FName>string</FName>
        <Encryption>string</Encryption>
      </TinName>
      <CurUser>
        <UserID>string</UserID>
        <UserLogin>string</UserLogin>
        <UserPassword>string</UserPassword>
        <UserEncryption>string</UserEncryption>
      </CurUser>
    </ValidateTinName>
  </soap:Body>
</soap:Envelope>

Open in new window

0
Comment
Question by:rivkamak
  • 2
3 Comments
 
LVL 52

Expert Comment

by:Scott Fell, EE MVE
ID: 39200145
This is a soap call.  You have to post the entire envelope.   For other languages like php and ruby, there are libraries to make this easy.  For those of us using ASP, we have to take the long way and convert the envelope (XML) to a string and post the string.    If you are using variable, place them in the xml as I have sampled.

if request.form("TIN")<>"" then ' test for data
     TIN=request.form("TIN")
     else
     TIN=""  ' make sure to not send null data
end if

theXML="<ValidateTinName xmlns=""******"">"  ' notice double quotes
theXML=theXML&"<TinName>"
theXML=theXML&"<TIN>"&TIN&"</TIN>"
       ' do this for each node
theXML=theXML&"</soap:Envelope>"

Set objHTTP =  CreateObject("WinHttp.WinHttpRequest.5.1")
vPostData = theXML
objHTTP.Open "POST", "https://www.****", false
objHTTP.Send  vPostData
response.write(objHTTP.ResponseText)

Open in new window

0
 

Author Comment

by:rivkamak
ID: 39200186
I fixed up the whole xml envelope.

What's with this error now?

The server cannot service the request because the media type is unsupported.
0
 
LVL 52

Accepted Solution

by:
Scott Fell,  EE MVE earned 500 total points
ID: 39200263
0

Featured Post

3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Why do we like using grid based layouts in website design? Let's look at the live examples of websites and compare them to grid based WordPress themes.
An enjoyable and seamless user experience can go a long way on an eCommerce site. While a cohesive layout and engaging copy play roles in creating a positive user experience, some sites neglect aspects that seem marginal but in actuality prove very …
Viewers will get an overview of the benefits and risks of using Bitcoin to accept payments. What Bitcoin is: Legality: Risks: Benefits: Which businesses are best suited?: Other things you should know: How to get started:
The viewer will get a basic understanding of what section 508 compliance can entail, learn about skip navigation links, alt text, transcripts, and font size controls.

911 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now