the_lone_note
asked on
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.
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.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
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
I can see the two parameters the request needs: busUnit, webOrder
And I can also see the response: response
ASKER
Does this seem correct?
I still do not know how to pass the credentials.
<%
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
%>
I still do not know how to pass the credentials.
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
The url you gave doesn't work for me, my guess is it's only accessible via the network you're on
ASKER
this are the contents of the first URL I posted.
ASKER
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!
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!
ASKER
I am putting this together:
But I get an exception on
I think that is because I need to write out the child node that contains the responsive and by looking at this XML structure:
The value I need is "response" in function "ARSWebOrderStatusServiceW ebOrderErr orResponse "
How can access this value?
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
But I get an exception on
.Write xmlDoc
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>
The value I need is "response" in function "ARSWebOrderStatusServiceW
How can access this value?
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
.Write xmlDoc
is not valid syntax, unless it's within some kind of WITH block. instead, try using:
Response.Write xmlDoc
ASKER
It is inside a with block.
can you post the full code you're using? it'll be easier to see exactly whats going on
ASKER
Here is the code:
This code call a class called SoapHelper.asp, it uses the function callSoapServiceXML, passing some parameters
This is the code of the callSoapServiceXML function:
And the XML is attached
arsweborderstatusservice.xml
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
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
And the XML is attached
arsweborderstatusservice.xml
Hey sorry for the lack of response, I was going to try to this either tonight or tomorrow. Did you get this working?
ASKER
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.
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.
ASKER
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.