"HTTP POST" XML cannot see node object in service

I am http posing a XML with content-type:“text/xml”; however, I cannot see the node object in service.

I see an input name as “<?xml version”, value is the rest of the xml string.

I use httpWebRequest from .net

thanks for help.

Shuren

What variable are you seeing in the service pipeline? Are you seeing $xmldata? Put a savepipeline at the first step and restore it to debug the pipeline.

If .net http posts xml with “text/xml” definetely you should see the *node object in the pipeline,this is standard notation.

HTH,
RMG

rmg,

Thanks for your reply. I already setup content-type=text/xml for HttpWebRequest.

I didn’t see the node object, that is my problem.
Also, after I add web reference by wsdl, there is no service name in proxy cs file, just a null class name, which means, I post xml without using wsdl.

I may ask you a question first, what the input should be, I only setup object ‘node’ as input. Do I need to put the document as input siganature?

As I know, for SOAP-MSG, I cannot put other parameter in input siganature.

Regards,

Shuren

You can directly post your XML to webMethods service through HTTP.

when your content-type = text/xml in the http header. webmethods content handler will convert the xml into node object and it will be available in your flow service.

I tried, but i cannot see the node.

Shuren

Can you post the snippet of code you’re using to do the http post?

here is the client side code from .net

==================================================
[highlight=c#]
messageBody = “<?xml version=\"1.0\" encoding=\"utf-8\"?><soap:Envelope xmlns:soap=”[url=“http://schemas.xmlsoap.org/soap/envelope/\"]http://schemas.xmlsoap.org/soap/envelope/[/url]" xmlns:xsi=”[url=“http://www.w3.org/2001/XMLSchema-instance\"]http://www.w3.org/2001/XMLSchema-instance[/url]" xmlns:xsd=“soap:Body<ServiceAdd”>http://www.w3.org/2001/XMLSchema”>soap:Body<ServiceAdd xmlns=“fe:FeWebServiceExample.SOAP_MSG.flow”><num1 xmlns="">123<num2 xmlns="">456</soap:Body></soap:Envelope>";

HttpWebRequest webRequest = (HttpWebRequest)WebRequest.Create(“http://montreappwmd01:5555/invoke/HTTP_POST.flow/srvHttpPostAdd”);

webRequest.Method = “POST”;

webRequest.ContentLength = messageBody.Length;
messageBytes = Encoding.UTF8.GetBytes(messageBody);

Stream requestStream = webRequest.GetRequestStream();
requestStream.Write(messageBytes,0,messageBytes.Length);
HttpWebResponse webResponse =null;
Stream responseStream = null;
webRequest.ContentType = “text/xml; charset=utf-8”;

try
{
webResponse = (HttpWebResponse)webRequest.GetResponse();
}
[/highlight]

Set the ContentType before getting the request stream–move line 15 up before line 11.

You don’t show a requestStream.close() so you’ll want to make sure you add that in if you don’t have that call.

if I set the ContentType before getting the request stream,
the file I get from SavePipelineToFile is:


 <?xml version="1.0" encoding="UTF-8"?>
<IDataXMLCoder version="1.0">
  <record javaclass="com.wm.util.Values">
    <value name="fileName">addHTTPPost</value>
  </record>
</IDataXMLCoder>

if I set the ContentType after getting the request stream,
the file I get from SavePipelineToFile is:


 <?xml version="1.0" encoding="UTF-8"?>
<IDataXMLCoder version="1.0">
  <record javaclass="com.wm.util.Values">
    <value name="fileName">addHTTPPost</value>
    <value name="<?xml version">"1.0" encoding="utf-8"?><soap:Envelope xmlns:soap="[URL="http://schemas.xmlsoap.org/soap/envelope/"]http://schemas.xmlsoap.org/soap/envelope/[/URL]" xmlns:xsi="[URL="http://www.w3.org/2001/XMLSchema-instance"]http://www.w3.org/2001/XMLSchema-instance[/URL]" xmlns:xsd="<A href="http://www.w3.org/2001/XMLSchema"><soap:Body><ServiceAdd">http://www.w3.org/2001/XMLSchema"><soap:Body><ServiceAdd xmlns="fe:FeWebServiceExample.SOAP_MSG.flow"><num1 xmlns="">100.6</num1><num2 xmlns="">200.5</num2></ServiceAdd></soap:Body></soap:Envelope></value>
    <array name="<?xml versionList" type="value" depth="1">
      <value>"1.0" encoding="utf-8"?><soap:Envelope xmlns:soap="[URL="http://schemas.xmlsoap.org/soap/envelope/"]http://schemas.xmlsoap.org/soap/envelope/[/URL]" xmlns:xsi="[URL="http://www.w3.org/2001/XMLSchema-instance"]http://www.w3.org/2001/XMLSchema-instance[/URL]" xmlns:xsd="<A href="http://www.w3.org/2001/XMLSchema"><soap:Body><ServiceAdd">http://www.w3.org/2001/XMLSchema"><soap:Body><ServiceAdd xmlns="fe:FeWebServiceExample.SOAP_MSG.flow"><num1 xmlns="">100.6</num1><num2 xmlns="">200.5</num2></ServiceAdd></soap:Body></soap:Envelope></value>
    </array>
  </record>
</IDataXMLCoder>

that is why I put it after streaming.

Shuren

The reason the second approach gets more data is because the content-type is the default (can’t remember the exact name) which causes IS to treat the data as name/value pairs–which is exactly what you’re seeing in the pipeline.

The content-type must be set before getting the request stream. I believe the problem is with the messageBody string such that IS cannot parse it properly. Does your code check the response that IS returns? Is there an error returned?

Can you post the string again and make sure that what is posted matches exactly what is in your code? It looks like the forum software munged your earlier post by converting parts of the string to URL references. Can you try it by using a very simple XML string which avoids namespaces?

***********************************************

 messageBody = "<?xml version=\"1.0\" encoding=\"utf-8\"?><soap:Envelope xmlns:soap=\"http://schemas.xmlsoap.org/soap/envelope/\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\"><soap:Body><ServiceAdd xmlns=\"fe:FeWebServiceExample.SOAP_MSG.flow\"><num1 xmlns=\"\">100.6</num1><num2 xmlns=\"\">200.5</num2></ServiceAdd></soap:Body></soap:Envelope>";

[SIZE=2]


File saved in pipeline is (tag characters are encoded automatically as is):


[/size]

 <?xml version="1.0" encoding="UTF-8"?>
<IDataXMLCoder version="1.0">
  <record javaclass="com.wm.util.Values">
    <value name="fileName">addHTTPPost</value>
    <value name="<?xml version">"1.0" encoding="utf-8"?><soap:Envelope xmlns:soap="[URL="http://schemas.xmlsoap.org/soap/envelope/"]http://schemas.xmlsoap.org/soap/envelope/[/URL]" xmlns:xsi="[URL="http://www.w3.org/2001/XMLSchema-instance"]http://www.w3.org/2001/XMLSchema-instance[/URL]" xmlns:xsd="<A href="http://www.w3.org/2001/XMLSchema"><soap:Body><ServiceAdd">http://www.w3.org/2001/XMLSchema"><soap:Body><ServiceAdd xmlns="fe:FeWebServiceExample.SOAP_MSG.flow"><num1 xmlns="">100.6</num1><num2 xmlns="">200.5</num2></ServiceAdd></soap:Body></soap:Envelope></value>
    <array name="<?xml versionList" type="value" depth="1">
      <value>"1.0" encoding="utf-8"?><soap:Envelope xmlns:soap="[URL="http://schemas.xmlsoap.org/soap/envelope/"]http://schemas.xmlsoap.org/soap/envelope/[/URL]" xmlns:xsi="[URL="http://www.w3.org/2001/XMLSchema-instance"]http://www.w3.org/2001/XMLSchema-instance[/URL]" xmlns:xsd="<A href="http://www.w3.org/2001/XMLSchema"><soap:Body><ServiceAdd">http://www.w3.org/2001/XMLSchema"><soap:Body><ServiceAdd xmlns="fe:FeWebServiceExample.SOAP_MSG.flow"><num1 xmlns="">100.6</num1><num2 xmlns="">200.5</num2></ServiceAdd></soap:Body></soap:Envelope></value>
    </array>
  </record>
</IDataXMLCoder>

[SIZE=2]


[/size]

Put the content type before getting the request stream. The node object is not persistable–it isn’t saved when you do a savepipelinetofile so you will never see it when you restorepipelinefromfile. Call pub.xml:xmlNodeToDocument in the service that is invoked and you should see your doc. The resulting doc can be saved with savepipelinetofile.

It doesn’t work.
I attached the pics before and after call pub.xml:xmlNodeToDocument

Shuren

You cannot use restorePipelineFromFile. It will never work. The node object is not saved with savePipelineToFile. Disable the call to restorePipelineFromFile. Do a SavePipelineToFile AFTER the call pub.xml:xmlNodeToDocument. Then run your program that does the post. Then run restorePipelineFromFile separately to see if the document made it.

It works!!! Thanks Reamon. You are great!
I see the DOCUMENT!

So, actually, no way to see the ‘node’, right?

Thanks lot

Shuren

Correct. The node is a Java object that cannot be viewed within Developer and has not been made serializable/saveable to work with the save/restorepipeline services. You’ll find this to be the case with virtually all Java objects within IS.

one more dig.

When I work on SOAP-MSG, the input/output has to be soapRequestData and soapResponseData object. However, I can call SavePipelineToFile at the top line, and I can see the soapRequestData, which is a string format. I hava to convert it to soap object though, I can see it at least.

So, what is the difference between ‘node’ in HTTPPOST and ‘soapRequestData’ in SOAP-MSG?

Shuren

SOAP messages take a different path. The URL used for SOAP directs the document to a different processor, which converts the document to soapRequestData before calling your service.