Solved

webservice different node levels

Posted on 2013-05-27
3
266 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 53

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 53

Accepted Solution

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

Featured Post

How To Reduce Deployment Times With Pre-Baked AMIs

Even if we can't include all the files in the base image, we can sometimes include some of the larger files that we would otherwise have to download, and we can also sometimes remove the most time-consuming steps. This can help a lot with reducing deployment times.

Question has a verified solution.

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

Because your company can’t afford for you to make SEO mistakes, you’ll want to ensure you’re taking the right steps each and every time you post a new piece of content. This list of optimization do’s and don’ts can help you become an SEO wizard.
Australian government abolished Visa 457 earlier this April and this article describes how this decision might affect Australian IT scene and IT experts.
The viewer will learn how to dynamically set the form action using jQuery.
Learn how to create flexible layouts using relative units in CSS.  New relative units added in CSS3 include vw(viewports width), vh(viewports height), vmin(minimum of viewports height and width), and vmax (maximum of viewports height and width).

636 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