Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Recieving WebMethods Post in ASP 3

Status
Not open for further replies.

CassidyHunt

IS-IT--Management
Joined
Jan 7, 2004
Messages
688
Location
US
I am trying to recieve a webmethods XML post in ASP. My code is as follows:

<%
dim sForm
dim m_objXML

set m_objXML = Server.Createobject("MSXML2.DOMDocument")
sForm = Request.Form()

m_objXML.loadXML (sForm)

if m_objXML.parseerror.number = 0 then
m_objXML.save (Server.mappath & "\test.xml")
Response.write m_objXML.xml
else
Response.write "Error has occured"
end if
%>


I recieve a post for a form when I have a name of the object or when I use the ServerXMLHTTP without a name. When webmethods post to me I see all the following:

HTTP_ACCEPT:image/gif, */* HTTP_HOST:209.193.95.45 HTTP_USER_AGENT:Mozilla/4.0 [en] (WinNT; I) HTTP_COOKIE:ASPSESSIONIDSQDQCABD=LDHNELODHOELCPAPOJJBFFHG HTTP_CONTENT_LENGTH:22116 HTTP_CONTENT_TYPE:text/xml

I can not access the data from the post. It shows I have 22116 bytes and returns 200 for success on the Webmethods machine.

Any idea how to get the data would be very appreciated.

Thanks.

Cassidy
 
I found out the problem but still do not have a good solution. When I change the post's encoding from text\xml to application/x- I am able to recieve the post and access the data. The company sending us the web methods post outside of the test environement insist on using text\xml.

Any ideas how to get around this? I was thinking maybe treating it as a file and using Request.BinaryRead.

Any ideas or suggestions would be welcomed.

Thanks

Cassidy
 
I would think request.Form ought to work for that. I don't know if it will make a difference, but have you tried it without the ()'s after the Request.Form?

-T

01000111 01101111 01110100 00100000 01000011 01101111 01100110 01100110 01100101 01100101 00111111
The never-completed website:
 
I have tried it without the (). What I have found doing research is that text\xml is type of MIME format like text\html. That is why I am having difficulty retrieving the data.

Here is the code you can use to simulate this:

<%
'Posting Page
dim m_objHTTPXML
dim m_objXML
dim sXML

set m_objXML = Server.CreateObject ("MSXML2.DOMDocument")

m_objXML.load ("PATH OF XML FILE HERE")
sXML = m_objXML.xml
Set m_objHTTPXML = Server.CreateObject("MSXML2.ServerXMLHTTP")
'Sending Order Acknowledgement
m_objHTTPXML.open "POST", "URL of Recieving page Here", False
m_objHTTPXML.setRequestHeader "Content-type", "text\xml" 'Change this to application/x- to work
m_objHTTPXML.send (sXML)

Response.write m_objHTTPXML.responseText
%>

The acceptance code is shown above. Depending on your variables for IIS you might have to change Server.Mappath to a physical location with write properties.

Let me know if you need help reporducing this or have any other ideas.

Thanks

Cassidy
 
Ok, solved part of the problem but still working on it. Apparently the information is not a string, so the first alterations I had to make were to remove the sForm variable and directly try:
m_objXML.load(Request)

Also, i'm not sure if its a versioning issue, but my DOMDocument didn't support ParseError.Number, I had to switch this to ParseError.Code. The message for the error number came from ParseError.Reason

I'm still getting an error (lack of top level tags) and I think that may be due to a 0 length value still, looking into it.

-T

01000111 01101111 01110100 00100000 01000011 01101111 01100110 01100110 01100101 01100101 00111111
The never-completed website:
 
That is exactly the same thing I have been running into. Thank you for trying. I am trying some new things with binary read to see if I can get the data in another format. Actually I can but have not written the parser to handle the binaryread after I get it. Let me know if you find a method that works without doing binaryread.

Thanks

Cassidy
 
I got it a while ago but lost my internet :P

Here are my two tet files:
Code:
[highlight]SendXML.asp[/highlight]
    <%
'Posting Page to post XML as text/xml
        dim m_objHTTPXML
        dim m_objXML
        dim sXML
        
        set m_objXML = Server.CreateObject ("MSXML2.DOMDocument")
        
        m_objXML.load (Server.MapPath("xml_Example.xml"))
		Response.Write "<div style=""border:1px solid black;margin-left:25px;"">XML Loaded: <xmp>" & m_objXML.xml & "</xmp>"
        sXML = m_objXML.xml
        Set m_objHTTPXML = Server.CreateObject("MSXML2.ServerXMLHTTP")    
            'Sending Order Acknowledgement
        m_objHTTPXML.open "POST", "[URL unfurl="true"]http://localhost/tt/RecvXML.asp",[/URL] False
        m_objHTTPXML.setRequestHeader "Content-type", "text\xml" 'Change this to application/x-[URL unfurl="true"]www-form-urlencoded[/URL] to work
        m_objHTTPXML.send (sXML)
        
        Response.Write "Results: " & m_objHTTPXML.ResponseText & "</div>"
    %>

[highlight]RecvXML.asp[/highlight]
<%
'reception of incoming POST'd text/xml file
dim sForm
dim m_objXML

set m_objXML = Server.Createobject("MSXML2.DOMDocument")

'On Error Resume Next
m_objXML.Async = False
m_objXML.load(Request)

If m_objXML.ParseError.ErrorCode = 0 then
   m_objXML.save (Server.mappath("test.xml"))
   Response.write "<div style=""border:1px solid black;margin-left:25px;""><h3>RecvXML.asp</h3>XML document received: " & len(m_objXML.xml) & " characters in document:<xmp>" & m_objXML.xml & "</xmp></div>"
Else
   Response.write "XML Parse Error(s) has/have occurred:" & m_objXML.ParseError.ErrorCode & ": " & m_objXML.ParseError.Reason & "<br>Document length: " & len(m_objXML.text) & "<br>Headers: " & Request.ServerVariables("ALL_HTTP")
End If
%>

This works now :)
The error I was receiving with the blank file was due to the fact that th file wasn't loading correctly, so I was passing an empty XML file :P

-T

01000111 01101111 01110100 00100000 01000011 01101111 01100110 01100110 01100101 01100101 00111111
The never-completed website:
 
Thank you. Your absolutly right. I was trying to load it incorrectly. Works perfect.

Thank you

Cassidy
 
Awesome as always Tarwn. :-)
 
Cassidy: Your quite welcome, I welcomed the chance to practice with those objects, haven't been doing as much XML stuf lately with any language (though I'm about to get back into gear with XML and VB.Net here shortly).

Veep: Thanks man, though I'm not sure the method I used should have worked. It bothers me that the same command to load an XML file (.load()) is also used for this POST'd text/xml ..(object?) thing. Now it's going to bother me as to why this works :P

01000111 01101111 01110100 00100000 01000011 01101111 01100110 01100110 01100101 01100101 00111111
The never-completed website:
 
this is a fantastic thread and has answered the question I've been looking for.

Tarwn / Cassidy you're asp gods!!! [2thumbsup]
 
Well, we were the gods of small brown clumps of moss, but we got bored so now we sit around all day in our dark room, drinking beverages, and answeriong questions...as opposed to sitting around all day in a dark room drinking bevarages and NOT answering questions ;)

Glad you found this useful, always happy to see this stuff get re-used byothers :)

-T

barcode_1.gif
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top