Using HTTP to post a file

I am using Business Connector 4.6. I have created a fixed length record flat file. It is in the pipeline as a string. I am wondering what the steps are to post this file to a https:// address using the HTTP service. Can you tell me the basic steps needed to do this and how to set the parameters in HTTP. I have a https address, a user id, and password. I can go to the address using a web browser and upload the file but I want to automate this from within BC. Thanks for any help.

Rebecca,

Here is the info of using that http service.
Set these parameters of service Input:

url-enter the destination https:\ipAddress
method-Post
data\string-directly map that flatfile string here
or
data\bytes-you can convert the flatfile string to bytes and map here
or
data\stream-you can convert the flatfile string to stream and map here if it is large file or so.
auth/type-set as Basic
auth/user-enter userid
auth/pass-enter password
headers/Content-type -explicitly create this param and set this to text/plain.

HTH,
RMG.

Thanks RMG. Where do I put the file name? I need to be able to name the file. Also, since I am posting to a https ip address, does this make this a secure transfer?

Rebecca,

In Http no need of putting filename,just you are posting the data and the target system will extract the data,if you want to do a filetransfer then basically use the pub.client:ftp service(but this is not a secure FTP).

HTH,
RMG.

Also regarding https transport you have to coordinate with the destination team and test the scenario if your IS giving any problems when posting the data to their https ip/port.
If it is not SSL handshaking process then you are fine and in the runtime your target server will do a encryption(publickey)verification,so contact your partner in this transaction.

Regards,

Hi,

i understand, that the post-method needs a service on the server-side. But my partner work with an iis 5.0 and there is only the put method available . Does anybody know what i have to do? When i try it, i ´ll get an error code like “HTTP/1.0 403 Forbidden”.

OK, I am able to use the http to ‘put’ a file to a https address. I set Content-Type=text/plain and passed the data as bytes. Now my question concerns passing the data as a stream. According to the documentation I must use ‘post’, is this correct? What is the setting of Content-Type? Do I need to set encoding? When trying to pass as a stream I am getting this error returned in BODY/bytes :

<!doctype>
<html><head>
<title>422 Unprocessable Entity</title>
</head><body>

Unprocessable Entity

The server understands the media type of the
request entity, but was unable to process the
contained instructions.
/aontest.txt: Permission denied. (POST)<p>
</body></html>

Rebecca,

Once you have converted the data as Stream object then map the stream to data/stream and also select loadAs=Stream (param in the pub.client:http) and content-type=text/plain should be fine unless if it is not XML type.

HTH,
RMG.

Hi All,

Our partner is using BizTalk server to post xml messages to our SAP BC
4.7.For some reason the default content-type for xml message is set to
text/plain in biztalk server.When we process the xml file with a service having DocumenToRecord as a stating point we get 403 Service Error.

Is there a way to receive the xml file sent by http post with content type text/plain.

Thanks very much.
rajammir

Raj,

Basically Content-Type should be text/xml,this is the only way of handling XML’s via http,so that WM content handler will handle the node object and parse it successfully.

HTH,
RMG

hi RMG,

Thanks for your reply.Is there a way we can receive xml file as a string.What method they should follow to send that as a string.

Thanks,
rajammir

text/xml is the easiest way to receive XML but it isn’t the only way. When the content-type is text/plain, a variable named ffdata will be in the pipeline when the service is called. This is an InputStream-derived object which can be passed to pub.io.streamToBytes. The resulting bytes can be passed to pub.string.bytesToString.

Raj, you don’t need the partner that is using BizTalk to make any changes. Change your service that they invoke to use the above steps (or whatever you need) and you’ll be set. You can go even further and make your receive service accept ffdata, node or a named string (such as “document” or “edidata”). That way your service can support content-types of text/plain, text/xml or an http get with a named var. The service would do these steps:

  • Check if node is not $null. If present, use it.
  • If node is $null, check for a named string. If present, convert it to a node.
  • If the named string is $null, check for ffdata. If present, convert to bytes, convert the bytes to a string, convert the string to a node.
  • If ffdata is $null, no usable data was passed. Return an error.
  • At this point, you have a node. Do whatever processing you need.

HTH.

Hi Rob,

From your above posting, if the partner sends an xml data as a stream with the content-type text/xml in HTTP post. what should be the name of the variable in the pipeline?

Thanks,
SATYA.

I got my answer.

The name of the variable in the pipeline is node object.

Thanks though.

Thanks,
SATYA.