TechData (Supplier) introduces a service that accepts XML message via POST request. So I can receive XML data with online prices and availibility information. But I don't have any idea how to begin.
I have to post a message to "http://intcom.xml.quality.techdata.de:8080/Onlchk".
Can anyone help me please? Thank you.
Maybe this will help?
Edit: Maybe there are other options. Progress version?
Message was edited by:
Simon de Kraa
progress 10.1B
Thanks for the information, i start testing now
hallo simon,
When i test the connection a receive the follow error:
connection failure
unknown host http://intcom.xml.techdata-europe.com:8080/Onlchk
My code to test conection:
DEFINE VARIABLE vcHost AS CHARACTER
INITIAL "http://intcom.xml.techdata-europe.com:8080/Onlchk"
NO-UNDO.
DEFINE VARIABLE vcPort AS CHARACTER INITIAL "8080" NO-UNDO.
DEFINE VARIABLE vhSocket AS HANDLE NO-UNDO.
CREATE SOCKET vhSocket.
vhSocket:CONNECT('-H ' + vcHost + ' -S ' + vcPort) NO-ERROR.
IF vhSocket:CONNECTED() = FALSE THEN
DO:
MESSAGE "Connection failure" VIEW-AS ALERT-BOX.
MESSAGE ERROR-STATUS:GET-MESSAGE(1) VIEW-AS ALERT-BOX.
RETURN.
END.
vhSocket:DISCONNECT() NO-ERROR.
Try intcom.xml.techdata-europe.com as the value for vcHost.
The host is just one part of the URL.
Thanks for the tip, but i still have the same error
This works for me... Is port 8080 blocked in your firewall? Do you need a Proxy server?
perfect, the connection is ok
but how can i reach the onlchk (online check) in
intcom.xml.techdata-europe.com:8080/onlchk
I'm very new to web services and stuff. So I will thank you for the help
This is handled in the PostRequest procedure.
You can do a "view source" (using your webbrowser) on the http page to check out the path and parameters.
i understand that i have to put /onlchk as parameter in PostRequest.
but first i have top upload an xml en than i receive the online check information.
So i have to run PostRequest first and then 'getResponse'?
How do i have to generate the request with the XML inside?
vcRequest = 'POST ' + "/Onlchk" + ' HTTP/1.0rn' +
'Content-Type: multipart/form-datarn' +
'Content-Length:' + string(LENGTH(postdata)) + 'rn' +
'rn' +
postData + 'rn'
A lot of questions, i know. Thanks again for all the help
Yes, I believe you have to somehow send the XML file with postrequest and then you will get a response that can be processed in getresponse.
Maybe this will help?
Did you ask the service provider if a SOAP version of the service is available somewhere? That would probably be the more efficient way of using the service.
I gonna ask
no, not available sorry
This link may be helpful: http://developers.sun.com/mobility/midp/ttips/HTTPPost/
The POST request consists of the
POST /Onlchk
Content-Length in bytesand
Content-Type: text/xml
followed by an empty line and then the XML document.
The documentation and samples CD/download from Progress contains a http get sample: src\samples\sockets\HTTP\Sockets-HTTP.p
It is relatively easy to build a POST out of it. Basically you need to look at the socked response handling procedure.
I can sent the post and i receive a response.
However, it's an error - no boundary found (see attached file)
Do yo now what it means?
Thanks
Kurt
I think you are close but have to set the boundary. See http://www.mail-archive.com/cactus-user@jakarta.apache.org/msg06500.html for an example.
I setted the boundary but i receive an new error java.util.NoSuchElementException
code:
vcRequest = "POST http://intcom.xml.techdata-europe.com:8080/Onlchk" + " HTTP/1.0" + "rn" +
"Content-Type:multipart/form-data; boundary=" + cBoundary + "rn" + cBoundary +
"Content-Disposition:form-data;name=xmlmsg" +
"rn" + "rn" +
postData + "rn" + cBoundary.
I'm not sure if this could be the problem but when you look at the examples in http://www.ietf.org/rfc/rfc1867.txt you see that there are additional "--" being used and you are not using them.
Content-type: multipart/form-data, boundary=AaB03x
--AaB03x
content-disposition: form-data; name="field1"
Joe Blow
--AaB03x
content-disposition: form-data; name="pics"; filename="file1.txt"
Content-Type: text/plain
... contents of file1.txt ...
AaB03x
i also tried that but with no success
vcRequest = 'POST http://intcom.xml.techdata-europe.com:8080/Onlchk HTTP/1.0rn' +
'Content-Type:multipart/form-data, boundary=' + cBoundary + 'rn' +
'Content-Length:' + string(LENGTH(postData)) + 'rn' +
'--' + cBoundary + 'rn' +
'Content-Disposition:form-data;name=xmlmsg' +
'rn' + 'rn' +
postData + 'rn'+
'' + cBoundary + ''.
ERROR: BAD REQUEST
Could you maybe post the value of the message here? (vcRequest)
vcRequest = 'POST http://intcom.xml.techdata-europe.com:8080/Onlchk HTTP/1.0rn' +
'Content-Type:multipart/form-data, boundary=' + cBoundary + 'rn' +
'Content-Length:' + string(LENGTH(postData)) + 'rn' +
'--' + cBoundary + 'rn' +
'Content-Disposition:form-data;name=xmlmsg' +
'rn' + 'rn' +
postData + 'rn'+
'' + cBoundary + ''.
I attached a picture with the response
Could you post the exact value of vcRequest?
Maybe you are missing some blank lines in the message?
Attached pic is the request I post
I received follow sample code from TechData
Dim lcString
Set FS = Wscript.CreateObject("Scripting.FileSystemObject")
If fs.FileExists("C:\eva\vbs\xml.txt") Then
Set ts = fs.OpenTextFile("C:\eva\vbs\xml.txt")
Do While Not ts.AtEndOfStream
lcString = lcString & ts.ReadLine
Loop
ts.Close
End If
lcUrl = "http://intcom.xml.techdata-europe.com:8080/Onlchk"
Set loXMLHTTP = CreateObject("MSXML2.ServerXMLHTTP")
lcBoundary = "7d7c3101d0bd2"
lcString = "" & lcBoundary & vbCrLf & "Content-Disposition : form-data; name=""xmlmsg""" & vbCrLf & vbCrLf & lcString & vbCrLf & "" & lcBoundary & "--"
loXMLHTTP.Open "POST",lcUrl,F
loXMLHTTP.setRequestHeader "Content-Type","multipart/form-data;boundary="+lcBoundary
loXMLHTTP.Send lcString
lstr_return=loXMLHTTP.responseXML.xml
WScript.Echo lstr_return
I already see two diffs:
Content-Disposition : form-data --> extra whitespace
multipart/form-data;boundary --> use of ; instead of ,
The message must be exactly the same.
that was stupid but ... still the same error
I'm desperate
Not sure, but you may need an additional blank line (crlf) after the Content-Length...
Maybe you can send your message to the website supplier for inspection?
I already did a couple of times, but i do not receive an answer
then I recive the error 413: request entity too large
Well, I do believe you need the extra CRLF so maybe there is a problem with the value of content-length and the actual length of the message?
I cheched the conent length and it seems ok
I'm not sure if the Content-Length matters but make sure you don't set it too low. Maybe add 10% too see if your message doesn't get truncated by the server?
Could you post the (ASCII) version of the exact message that you are sending?
POST http://intcom.xml.techdata-europe.com:8080/Onlchk HTTP/1.0
Content-Type: multipart/form-data; boundary=7d7c3101d0bd2
Content-Length: 338
--7d7c3101d0bd2
Content-Disposition : form-data; name=xmlmsg
7d7c3101d0bd2
Your XML message alone is longer than your content-length...
(and you definitely need the addtional CRLF after the content-length)
cat xmlmsg
wc xmlmsg
13 16 343 xmlmsg
I deleted the line with the content-length.
Now, I receive a HTTP/1.1 200 response but also with an error (see attached file)
I think that is a (little) step forwards
But you still have the blank line after the conten-type right?
What happens if you fiddle around with the XML message? Delete the header or shorten the XML message or delete the XML message entirely.
stays the same
sorry
Cr@p!
I'm running out of ideas Kurt...
Maybe someone else can chip in?
no problem !!!
But I received a mail from Techdata and now they ay that a SOAP version is available. But because needs for every new session an new authentication code, almost nobody uses this method.
I can try it but I don't know anything about SOAP!!! So, again, Your help is very very welkom
Kurt
Hello again,
can you please help me out with trying the SOAP version?
I run out of time to implement to online check!
Thank you
I suggest you open a new thread with the specs.
You are very close. However, the action of the form is /TechDataTouchIn/GatewayServlet so that is where the POST should go (rather than to /Onlcheck).
So for instance something like this should work:
POST http://intcom.xml.techdata-europe.com:8080/TechDataTouchIn/GatewayServlet HTTP/1.0
Content-Type: multipart/form-data; boundary=asdfzxcvqwer
--asdfzxcvqwer
Content-Disposition: form-data; name="file"; filename="xmlmsg.xml"
Content-Type: text/xml
122292
1s16QI2q-F9Jt-n25d-AdOH-IcWc9ZK8d27G
Full
1593371
1
--asdfzxcvqwer--
(I have no idea how this is going to format and I don't see a preview option!)
When I test this, I get an error saying I'm not authorized to use the page. I get the same error if I use my browser so I'm guessing it pretty much works.