Problem sending XML data using HTTP Post

Hello,

I have a problem sending xml data using Http post. i am getting the following error:

  1. XMLCoder decode invalid data type: com.wm.app.tn.tspace.Reservation_FileImpl
    2)XMLCoder decode invalid data type: com.wm.lang.xml.Document

specifications:
IS: 6.0.1

service-in details of Http:

url : http://servername:portname/invoke/folder/servicename
method: Post
data: string
auth : suername & password
header content-type : text/xml

Please let me know if u have any idea about this.

Thanks
chags

What data is in the XML? Based on the error message it looks like objects that are not passable via XML are being used. There should really be no reason to be trying to pass the two object types listed using XML over HTTP. Can you share more about what you’re trying to accomplish?

I am trying to send the xml data to the test server and from there sending it to the AS400.
The above errors i can see in the test server where i am trying to send the xml data.

Thanks
Nipun

Nipun,

What is your invoking service input type?? It should be node(object)…
XMLNodeToDocument (as first step of the service)

Also make sure your xml is wellformed xml string.

HTH,
RMG

hello,

the input that i am using in the test server where i am sending the data is node (object).
the error i am getting now:

Copy failed: No source data available: to=/bytes, from=/node

Thanks,
chags

One more time: “What data is in the XML?”
Please post the XML that you’re having trouble with.

Hello,

Problem resolved. Since we were getting large files i had this problem sending the data using HTTPPost. I have used node iterator and have send each node using HTTP to my test server. Everything works fine now.

Thanks a lot for your help.

chags

Uh!! largefile,you are in right track with nodeiterator,getnextnode etc…

Glad it know it worked.

HTH,
RMG

Did you ever fix this? I’m have the same issue.

Yes i did… let me know what is the exact problem that you are facing.

I’m using pub.client.http to send xml from one service (service1) to another (service2).

Service1 simply takes and an xml file and sends it to service2.
pub.client.http variables are set as follows:
url=http://localhost:5555/invoke/test.folder/testSvc
method=post
loadAs=bytes
Content-Type=text/xml
user=Administrator
pass=manage

After the call, I get a 403 response. Looking at the server log I see “Copy failed: No source data available: to=/node, from=/input”

Service2 has a node (input) as the input. It takes input and does a xmlNodeToDocument. That’s where the exception is triggered, but it seems like service2 never successfully gets in the input.

I get the same error if I test service2 through the browser. It works if I do an inline call from service1 to service2 and if I test it through developer/Test/SendXMLFile. But, I’m testing functionality so I really need to use http.

My test data looks like this:

<?xml version="1.0" encoding="UTF-8"?> 1 1111 1867 george washington 5555555555

Thanks for you help.

If it is a large file then there is a problem with HTTP service, so I wrote the xml to a file using writetofile service and then called this xmlfile using [FONT=ArialNarrow,Bold][SIZE=4]

pub.xml:loadXMLNode service.

[/size][/font][FONT=ArialNarrow,Bold][SIZE=4]

[LEFT]
Or second option: You can use XML node iterator and send each node at one time to the 2nd service using HTTP. You can get a sample package in wmusers how to use node iterator.[/size][/font]

Thanks
Chags
[/LEFT]

Why are you using an HTTP post to send an XML file from one Flow service to another? This is not necessary. If you need to test service2 by sending an XML file use Developer’s Test->Send XML File menu option to do this.

Mark

I’m just testing functionality. I’m having each simulate an external system. Eventually, one service will send a request to an external system and expect a response in the same session. The other will receive a request from an external system and send a response in the same session. Basically, I’m just using the flow services to test each other. However, if I can’t get them to work together, then I don’t have much hope of being able to interface with the external systems.

This is pretty basic stuff and is covered in the built-in services guide for pub.client:http as well as some references on sending XML to a service in the Developer’s guide.

How are you mapping your XML doc into the pub.client:http service? Did you choose “text/xml” as the content type?

This works every time if done correctly.

Mark

Yeah, I know it’s basic. That’s why I was so frustrated. I poured over both documents multiple times before I submitted my issue.

It wasn’t until I stumbed across this obscure little line in the documentation that I finally got it to work.

“When you submit the XML document, place an extra carriage return/new line
(\r\n) at the end of it to indicate the end of the XML document.”

Thanks guys for all the help. I appreciate it.

The problem continues…

If I hard code the xml and the \r\n into xmldata and then map xmldata to the data/string input of pub.client.http everything works fine. But, since this is hardcoding the input, I can’t do this.

However, if I use variable substitution (%xmldata%\r\n), pub.string.concat, or pub.string.makeString, it stops working.

I’ve already searched this site, the built-in services docs, developer docs, etc.

Format 1 – works

<?xml version="1.0" encoding="UTF-8"?> 1 1111 1867 george washington 5555555555 \r\n

Format 2 (string substitution turn on) – doesn’t work

%xmldata%\r\n

With either format I use, the pipeline values looks the same, so I’m guessing wm does something different in the special characters that I can’t see.

Thanks in advance for your help.

I experimented with this issue by writing two pairs of services:

tryHttpPost —> receiveHttpPost
and
tryHttpGet —> receiveHttpGet

The try version sends an xml string to the receive version. Both work ok.

Further, I tested the receive services by mean of a browser (url for GET, and a form for POST). Both receivers worked ok.

The services are simple, but too difficult to explain in this thread. I have attached the packages to this thread.

The packages’ pub folder contains html files that can be used to run the receive services via a browser. The services can also be run with Developer.
tryHttpGet.zip (9.99 KB)
tryHttpPost.zip (10 KB)

ladson,

Thanks for your help.

I’m doing almost the exact same thing as you. If I start with the tryHttpPost, everthing works fine. However, if I call tryHttpPost from another service and the data happens to have been in a node or document at one point it doesn’t work.

Please take a look at my small project. Use the starter as the entry point and see what results you get.

I’ve included the export and the xsd for the doc.

Thanks
httpTest.zip (13.2 KB)
testDoc.zip (436 Bytes)

I added a service called preStarter which calls starter with a node as input. It appears to work ok. I also renamed your document type from testDoc to testDocWrapper, to avoid confusion between the doc type (originally testDoc)and its top level element (also testDoc)

I think you may have been confused by the nesting of the doc (at least I was).

The debug log looks like this (note, I also changed the server to localhost):

 2006-09-15 14:19:41 EDT [ISP.0090.0003C] starter is about to send : <?xml version="1.0"?>
<testDoc>
  <uniqueID>myUniqueID</uniqueID>
  <senderID>mySenderID</senderID>
  <receiverID>myReceiverID</receiverID>
  <data>
    <firstName>myFirstName</firstName>
    <lastName>myLastName</lastName>
    <homePhone>myHomePhone</homePhone>
  </data>
</testDoc>
2006-09-15 14:19:41 EDT [ISP.0090.0003C] httpPost is about to send xmldata=<?xml version="1.0"?>
<testDoc>
  <uniqueID>myUniqueID</uniqueID>
  <senderID>mySenderID</senderID>
  <receiverID>myReceiverID</receiverID>
  <data>
    <firstName>myFirstName</firstName>
    <lastName>myLastName</lastName>
    <homePhone>myHomePhone</homePhone>
  </data>
</testDoc>
2006-09-15 14:19:41 EDT [ISP.0090.0003C] receiveHttpPost got : <?xml version="1.0"?>
<testDoc>
  <uniqueID>myUniqueID</uniqueID>
  <senderID>mySenderID</senderID>
  <receiverID>myReceiverID</receiverID>
  <data>
    <firstName>myFirstName</firstName>
    <lastName>myLastName</lastName>
    <homePhone>myHomePhone</homePhone>
  </data>
</testDoc>
2006-09-15 14:19:41 EDT [ISP.0090.0003C] receiveHttpPost response : <?xml version="1.0"?>
<testDoc>
  <uniqueID>myUniqueID</uniqueID>
  <senderID>myReceiverID</senderID>
  <receiverID>mySenderID</receiverID>
  <data>
    <firstName>myLastName</firstName>
    <lastName>myFirstName</lastName>
    <homePhone>myHomePhone</homePhone>
  </data>
</testDoc>
2006-09-15 14:19:41 EDT [ISP.0090.0003C] httpPost response : <?xml version="1.0"?>
<testDoc>
  <uniqueID>myUniqueID</uniqueID>
  <senderID>myReceiverID</senderID>
  <receiverID>mySenderID</receiverID>
  <data>
    <firstName>myLastName</firstName>
    <lastName>myFirstName</lastName>
    <homePhone>myHomePhone</homePhone>
  </data>
</testDoc>

I hope this helps.
httpTest2.zip (16.2 KB)