how to consume a wfc using classic asp.

I have to consume a web service (svc) from this url:

http://brlaxappdev.ariens.corporate/MicrosoftDynamicsAXAif50/arsweborderstatusservice.svc


I have not worked with web services very much, and the experience I have is with asp.net only, and not much.

The web service returns a webOrderError for orders that are not processed successfully.

Will it be possible someone in this forum can help me out with some code examples on how to do this, using the XML of the URL included?

Many thanks.
the_lone_noteAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Big MontySenior Web Developer / CEO of ExchangeTree.org Commented:
you can use something like the code below. you just need to tailor it to include whatever data you may be sending over to the web service:

   url = "http://brlaxappdev.ariens.corporate/MicrosoftDynamicsAXAif50/arsweborderstatusservice.svc"
   postdata = "data to send"
    Set xmlhttp = CreateObject("MSXML2.ServerXMLHTTP.6.0")
    xmlhttp.open "POST", url, false
    xmlhttp.setRequestHeader "Content-Type", "text/xml; charset=utf-8" 
    '-- any other headers you need to set, do it here
    xmlhttp.send postdata
    xml = xmlhttp.responseText

Open in new window

0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
the_lone_noteAuthor Commented:
Thank you Big Monty.

How would I need to modify  the code you posted, if I need to pass two parameters lie: orderId and siteKey, and get a  text string response?

Also, I need to supply credentials such as username, password, and domain; well at least that is how I do it on .NET.

Many thanks.
0
the_lone_noteAuthor Commented:
If I run this URL: http://brlaxappdev.ariens.corporate/MicrosoftDynamicsAXAif50/arsweborderstatusservice.svc?xsd=xsd0

I can see the two parameters the request needs: busUnit, webOrder
And I can also see the response: response
0
Cloud Class® Course: CompTIA Cloud+

The CompTIA Cloud+ Basic training course will teach you about cloud concepts and models, data storage, networking, and network infrastructure.

the_lone_noteAuthor Commented:
Does this seem correct?

<% 

	Dim xmlhttp
	Dim PostData
	Dim	postUrl
	Dim xml	
	
	postUrl = "http://brlaxappdev.ariens.corporate/MicrosoftDynamicsAXAif50/arsweborderstatusservice.svc"
	Set xmlhttp = Server.CreateObject("MSXML2.ServerXMLHTTP.6.0")
	PostData = "_webOrder=" & strOrderNo
	PostData = PostData & "&_busUnit=" & strSite	
	xmlhttp.Open "POST", postUrl, false
	xmlhttp.setRequestHeader "Content-Type", "application/x-www-form-urlencoded"	
	
	On Error Resume Next	
	xmlhttp.send PostData	
	xml = xmlhttp.ResponseText
%>

Open in new window


I still do not know how to pass the credentials.
0
Big MontySenior Web Developer / CEO of ExchangeTree.org Commented:
is this a SOAP webservice you're sending too?

The url you gave doesn't work for me, my guess is it's only accessible via the network you're on
0
the_lone_noteAuthor Commented:
this are the contents of the first URL I posted.
0
the_lone_noteAuthor Commented:
0
Big MontySenior Web Developer / CEO of ExchangeTree.org Commented:
it does appear to be using SOAP, which is good...

I got to run to a meeting for a few hours, but wanted to also pass along this example to you:

http://www.codeproject.com/Articles/20125/Using-SOAP-With-Classic-ASP-VBScript

essentially you want to create the xml you'll be passing along, which would include your different parameters. The format of that xml would be based off what the web service is expecting. if the parameters are not part of the xml format the web service defines, try appending those parameters as querystring variables in the url you call.

good luck!
0
the_lone_noteAuthor Commented:
I am putting this together:

                                Dim soapHelper2
                                Set soapHelper2 = new SoapHelper
                                Dim xmlDoc
                                Dim strURL
                                strURL = "http://brlaxappdev.ariens.corporate/MicrosoftDynamicsAXAif50/arsweborderstatusservice.svc"
                                Dim StrFunctionName
                                StrFunctionName =  "ARSWebOrderStatusServiceWebOrderErrorRequest"
                                Dim strInterfaceName
                                strInterfaceName = "ARSWebOrderStatusService"
                                Dim strXML
                                strXML = "<_busUnit>" & siteoverride & "00" & "</_busUnit>" 
                                strXML = strXML & "<_webOrder>" & strOrderId & "</_webOrder>"

                                If field = "Error" Then 
                                    Set xmlDoc = soapHelper2.callSoapServiceXML(strURL, StrFunctionName, strInterfaceName, strXML)                                    
                                    .Write xmlDoc
                                Else 
                                    .Write field
                                End If 

Open in new window



But I get an exception on
.Write xmlDoc

Open in new window


I think that is because I need to write out the child node that contains the responsive and by looking at this XML structure:

<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:tns="http://schemas.microsoft.com/dynamics/2008/01/services" elementFormDefault="qualified" targetNamespace="http://schemas.microsoft.com/dynamics/2008/01/services">
<xs:element name="ARSWebOrderStatusServiceWebOrderErrorRequest">
<xs:complexType>
<xs:sequence>
<xs:element minOccurs="0" name="_busUnit" nillable="true" type="xs:string"/>
<xs:element minOccurs="0" name="_webOrder" nillable="true" type="xs:string"/>
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name="ARSWebOrderStatusServiceWebOrderErrorResponse">
<xs:complexType>
<xs:sequence>
<xs:element minOccurs="0" name="response" nillable="true" type="xs:string"/>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:schema>

Open in new window


The value I need is "response" in function "ARSWebOrderStatusServiceWebOrderErrorResponse"

How can access this value?
0
Big MontySenior Web Developer / CEO of ExchangeTree.org Commented:
you're getting an error because

.Write xmlDoc

is not valid syntax, unless it's within some kind of WITH block. instead, try using:

Response.Write xmlDoc
0
the_lone_noteAuthor Commented:
It is inside a with block.
0
Big MontySenior Web Developer / CEO of ExchangeTree.org Commented:
can you post the full code you're using? it'll be easier to see exactly whats going on
0
the_lone_noteAuthor Commented:
Here is the code:

This code call a class called SoapHelper.asp, it  uses the function callSoapServiceXML, passing some parameters
Dim soapHelper2
Set soapHelper2 = new SoapHelper                                
Dim strURL                                
Dim strFunctionName                                
Dim strInterfaceName                                
Dim strXML
Dim strNode
Dim xmlDoc

strURL = "http://network.corporate/MicrosoftDynamicsAXAif50/arsweborderstatusservice.svc"
strFunctionName =  "ARSWebOrderStatusServiceWebOrderErrorRequest"
strInterfaceName = "ARSWebOrderStatusService"

strXML = "<_busUnit>" & siteoverride & "00" & "</_busUnit>" 
strXML = strXML & "<_webOrder>" & strOrderId & "</_webOrder>"

If field = "Error" Then 
    Set xmlDoc = soapHelper2.callSoapServiceXML(strURL, strFunctionName, strInterfaceName, strXML)
    If Not IsNull(xmlDoc) Then 
        For Each strNode In xmlDoc.childNodes
            .Write strNode.text                                    
    Next
    End If
Else 
    .Write field
End If

Open in new window


This is the code of the callSoapServiceXML function:

    Function callSoapServiceXML(serviceURL, functionName, interfacename, strXML)
        dim objXML
        set objXML = Server.CreateObject("Microsoft.XMLDOM")

        Dim soapMessage
	    soapMessage = "<s:Envelope xmlns:s=" & GetQuotedUrl("http://schemas.xmlsoap.org/soap/envelope/") & ">" & _
	    					"<s:Body>" & _
	    						"<" & functionName & " xmlns=" & GetQuotedUrl("http://tempuri.org/") & ">"

                                 soapMessage = soapMessage & strXML

                                soapMessage = soapMessage & "</" & functionName & ">" & _
	    					"</s:Body>" & _
	    				"</s:Envelope>"

	    soapMessage = Replace(soapMessage, "'", chr(34))
        dim xmlhttp
        dim post
	    Set xmlhttp = CreateObject("MSXML2.ServerXMLHTTP")

	    xmlhttp.open "POST", serviceURL, False
	    xmlhttp.setRequestHeader "Man", POST & " " & serviceURL & " HTTP/1.1"
	    xmlhttp.setRequestHeader "SOAPAction", "http://tempuri.org/" & interfacename & "/"& functionName
	    xmlhttp.setRequestHeader "Content-Type", "text/xml; charset=utf-8"

	    xmlhttp.send(soapMessage)
        if objXML.load(xmlhttp.responsebody) then
		    'Response.Write(xmlhttp.responseText & "<br><br>")
		else
		    'response.Write("XML load error.")
	    end if

        set callSoapServiceXML = objXML.selectSingleNode("/s:Envelope/s:Body/" & functionName & "Response/" & functionName & "Result")
    end Function

    Function GetQuotedUrl(ByVal value)
        GetQuotedUrl = Chr(34) & value & Chr(34)
    End Function

Open in new window


And the XML is attached
arsweborderstatusservice.xml
0
Big MontySenior Web Developer / CEO of ExchangeTree.org Commented:
Hey sorry for the lack of response, I was going to try to this either tonight or tomorrow. Did you get this working?
0
the_lone_noteAuthor Commented:
I have to consume this service to two websites, one is .net, and the other is classic asp. The .net solution is already consuming the web service how it is supposed to, and it was a lot of trouble for me to have this working with Classic ASP, especially having to pass the network authentication in order to retrieve the message returned from the web service.

What I did is to create a simple page inside the .net project that would popup when the user clicks the error link on the classic asp site, and that page would popup (using fancy box).  The page calls the existing functions in the .net solution to get the error message.

That, to me, was in the end the easiest since it was already done in there.

I granted you the points because I thought it was fair to you, since you were kindly investing your time in helping me.

Best regards.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
ASP

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.