How to Post Map Message to Rest/HTTP Post URL

classic Classic list List threaded Threaded
7 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

How to Post Map Message to Rest/HTTP Post URL

bsri81@gmail.com
This post has NOT been accepted by the mailing list yet.
Hi,

I need to post message to REST url or HTTP Post URL and need to pass Map message body like below:
"xml_data=<?xml version="1.0" encoding="utf-8"?>
<root><success>True</success><response><message>GET is not supported</message></response></root>"
And Content type for posting is "application/x-www-form-urlencoded"

In Other cases i am able to post xml data directly, but here it requires "name=xml_value" format, Map format.

How to Post Map Message to Rest/HTTP Post URL ? What should be message type, property should be used.

Please suggest.

Regards,
Sri

Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

RE: How to Post Map Message to Rest/HTTP Post URL

vishnu.piskala

What you actually wanted to post is a simple xml message but you are choosing wrong content type. The content type for xml is application/xml.

 

 

 

From: [hidden email] [via OpenESB Community Forum] [mailto:[hidden email]]
Sent: Thursday, May 11, 2017 2:52 AM
To: vishnu.piskala <[hidden email]>
Subject: How to Post Map Message to Rest/HTTP Post URL

 

Hi,

I need to post message to REST url or HTTP Post URL and need to pass Map message body like below:
"xml_data=<?xml version="1.0" encoding="utf-8"?>
<root><success>True</success><response><message>GET is not supported</message></response></root>"
And Content type for posting is "application/x-www-form-urlencoded"

In Other cases i am able to post xml data directly, but here it requires "name=xml_value" format, Map format.

How to Post Map Message to Rest/HTTP Post URL ? What should be message type, property should be used.

Please suggest.

Regards,
Sri



If you reply to this email, your message will be added to the discussion below:

http://openesb-community-forum.794670.n2.nabble.com/How-to-Post-Map-Message-to-Rest-HTTP-Post-URL-tp7581614.html

To start a new topic under OpenESB Community Forum, email [hidden email]
To unsubscribe from OpenESB Community Forum, click here.
NAML

Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

RE: How to Post Map Message to Rest/HTTP Post URL

vishnu.piskala
In reply to this post by bsri81@gmail.com

What you actually wanted to post is a simple xml message but you are choosing wrong content type. The content type for xml is application/xml.

 

Regards

Vishnu

www.logicoy.com

 

 

 

 

From: [hidden email] [via OpenESB Community Forum] [mailto:[hidden email]]
Sent: Thursday, May 11, 2017 2:52 AM
To: vishnu.piskala <[hidden email]>
Subject: How to Post Map Message to Rest/HTTP Post URL

 

Hi,

I need to post message to REST url or HTTP Post URL and need to pass Map message body like below:
"xml_data=<?xml version="1.0" encoding="utf-8"?>
<root><success>True</success><response><message>GET is not supported</message></response></root>"
And Content type for posting is "application/x-www-form-urlencoded"

In Other cases i am able to post xml data directly, but here it requires "name=xml_value" format, Map format.

How to Post Map Message to Rest/HTTP Post URL ? What should be message type, property should be used.

Please suggest.

Regards,
Sri


If you reply to this email, your message will be added to the discussion below:

http://openesb-community-forum.794670.n2.nabble.com/How-to-Post-Map-Message-to-Rest-HTTP-Post-URL-tp7581614.html

To start a new topic under OpenESB Community Forum, email [hidden email]
To unsubscribe from OpenESB Community Forum, click here.
NAML

Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

RE: How to Post Map Message to Rest/HTTP Post URL

bsri81@gmail.com
This post has NOT been accepted by the mailing list yet.
Thanks for Reply, I cant use "application/xml" it throws "Unknown Exception".
REST API is 3rd party service which mentioned to use "application/x-www-form-urlencoded" only and body message expects in java.util.map format.
How to configure in Rest Adapter.

As said request is in "name=value" format.

Regards,
Sri
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

RE: How to Post Map Message to Rest/HTTP Post URL

vishnu.piskala

May be your server expects in JSON format..which is close to map format but certainly not java.util.Map format.

 

REST BC can automatically convert the xml request to JSON. Try setting the content-type in CDATA section to application/x-www-form-urlencoded and observe what is being sent to the server using a tool like tcpmon or fiddler.

 

I suggest you to first try sending a sample request using chrome apps like POSTMAN and make sure what request your server expects and responds successfully. This will help you to troubleshoot your issues and then you can make changes REST BC wsdl accordingly.

 

Thanks

Vishnu

www.logicoy.com

 

From: [hidden email] [via OpenESB Community Forum] [mailto:[hidden email]]
Sent: Thursday, May 11, 2017 4:36 PM
To: vishnu.piskala <[hidden email]>
Subject: RE: How to Post Map Message to Rest/HTTP Post URL

 

Thanks for Reply, I cant use "application/xml" it throws "Unknown Exception".
REST API is 3rd party service which mentioned to use "application/x-www-form-urlencoded" only and body message expects in java.util.map format.
How to configure in Rest Adapter.

As said request is in "name=value" format.

Regards,
Sri


If you reply to this email, your message will be added to the discussion below:

http://openesb-community-forum.794670.n2.nabble.com/How-to-Post-Map-Message-to-Rest-HTTP-Post-URL-tp7581614p7581619.html

To start a new topic under OpenESB Community Forum, email [hidden email]
To unsubscribe from OpenESB Community Forum, click here.
NAML

Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

RE: How to Post Map Message to Rest/HTTP Post URL

bsri81@gmail.com
This post has NOT been accepted by the mailing list yet.
I tested REST service in POSTMAN and SOAP UI,

When content type = "application/x-www-form-urlencoded"
and request body should be is, for Ex:
"xml_data=<Data xmlns="http://j2ee.netbeans.org/xsd/Target"> <Header xmlns=""> <DocumentVersion>1.0</DocumentVersion> <MessageId>str1234</MessageId> </Header> </Data>"
Its successfully processing.

But in REST parameter i tried concatenating as String/hard code (for Ex: "xml_data=<Data xmlns="http://j2ee.netbeans.org/xsd/Target"> <Header xmlns=""> <DocumentVersion>1.0</DocumentVersion> <MessageId>str1234</MessageId> </Header> </Data>") and send as REST parameter value throwing error.
I also tried creating 2 parts for REST one for "xml_data" and another for "<Data xmlns="http://j2ee.netbeans.org/xsd/Target"> <Header xmlns=""> <DocumentVersion>1.0</DocumentVersion> <MessageId>str1234</MessageId> </Header> </Data>"
throwing error.


Formatting and sending message in REST Adapter/WSDL is an issue or missed something ?

Any suggestion ?

REST WSDL format:
------------------------------------------------------------
<definitions name="Rest_WSDL"
    targetNamespace="http://j2ee.netbeans.org/wsdl/PO_Header/src/Rest_WSDL"
    xmlns="http://schemas.xmlsoap.org/wsdl/"
    xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
    xmlns:mime="http://schemas.xmlsoap.org/wsdl/mime/"
    xmlns:xsd="http://www.w3.org/2001/XMLSchema"
    xmlns:rest="http://schemas.sun.com/jbi/wsdl-extensions/rest/"
    xmlns:plnk="http://docs.oasis-open.org/wsbpel/2.0/plnktype" xmlns:tns="http://j2ee.netbeans.org/wsdl/PO_Header/src/Rest_WSDL" xmlns:ns0="http://j2ee.netbeans.org/xsd/Target" xmlns:ns1="http://xml.netbeans.org/schema/input" xmlns:ns2="http://xml.netbeans.org/schema/root">
    <types>
        <xsd:schema targetNamespace="http://j2ee.netbeans.org/wsdl/PO_Header/src/Rest_WSDL">
            <xsd:import namespace="http://j2ee.netbeans.org/xsd/Target" schemaLocation="Target.xsd"/>
            <xsd:import namespace="http://xml.netbeans.org/schema/input" schemaLocation="input.xsd"/>
            <xsd:import namespace="http://xml.netbeans.org/schema/root" schemaLocation="root.xsd"/>
        </xsd:schema>
    </types>
    <message name="Rest_Call_PostRequest">
        <part name="Data" type="xsd:anyType"/>
       
    </message>
    <message name="Rest_Call_PostResponse">
        <part name="part1" type="xsd:anyType"/>
    </message>
    <portType name="RestOutboundPortType">
        <operation name="Rest_Call_Post">
            <input name="Rest_Call_PostInput" xmlns:tns="http://j2ee.netbeans.org/wsdl/PO_Header/src/Rest_WSDL" message="tns:Rest_Call_PostRequest"/>
            <output name="Rest_Call_PostOutput" xmlns:tns="http://j2ee.netbeans.org/wsdl/PO_Header/src/Rest_WSDL" message="tns:Rest_Call_PostResponse"/>
        </operation>
    </portType>
    <binding name="RestOutboundBinding" type="tns:RestOutboundPortType">
        <rest:binding/>
        <operation name="Rest_Call_Post">
            <rest:operation>
<![CDATA[
# required, URL of external resource
# for example: http://somehost.com/users/{id}/address
url=URL

# optional, HTTP verb to access the resource, defaults to GET
method=POST

# optional, acceptable media types of response can be added as array elements in JSON format
accept-types=[ "application/xml" ]

# optional, preferred natural languages for the response, added as array elements in JSON format
accept-languages=[ ]

# optional, content type of outgoing payload, defaults to any type
content-type=application/x-www-form-urlencoded

# optional, additional custom HTTP headers can be added as pairs in JSON format in this property
# for example:  { "authorization" : "257984234", "last-modifed" : "2009-04-23:12:00:00" }
headers={ }

# optional, style for the parameters, valid values are QUERY, MATRIX, defaults to QUERY
param-style=Query

# optional, additional custom HTTP parameters can be added as pairs in JSON format in this property
# for example:  { "userid" : "abc" , "userpassword" : "123" }
params={ }

# optional, adding HTTP Basic Authentication header to the HTTP request,
# if the two properties below are specified
basic-auth-username=XXXXXXX
basic-auth-password=YYYYYYY

]]></rest:operation>
            <input name="Rest_Call_PostInput">
                <mime:content part="Rest_Call_PostRequest" type="application/x-www-form-urlencoded"/>
            </input>
            <output name="Rest_Call_PostOutput"/>
        </operation>
    </binding>
    <service name="RestOutboundService">
        <port name="RestOutboundWSDL_OutboundPort" binding="tns:RestOutboundBinding">
            <rest:address/>
        </port>
    </service>
    <plnk:partnerLinkType name="RestOutboundWSDL">
       
        <plnk:role name="RestOutboundPortTypeRole" portType="tns:RestOutboundPortType"/>
    </plnk:partnerLinkType>
</definitions>


Regards,
Sri
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

RE: How to Post Map Message to Rest/HTTP Post URL

vishnu.piskala

OpenESB’s REST BC supports posting of JSON or XML data. But what you have is not valid xml data (since you have “xml_data=” in front of the actual xml). I don’t know how to do it. If given time I can try and see if I can get it working with REST BC. But simpler solution is to use a POJO SE and invoke the REST URL using jersey or some other framework.

 

Regards

Vishnu

www.logicoy.com

 

 

From: [hidden email] [via OpenESB Community Forum] [mailto:[hidden email]]
Sent: Friday, May 12, 2017 4:28 AM
To: vishnu.piskala <[hidden email]>
Subject: RE: How to Post Map Message to Rest/HTTP Post URL

 

I tested REST service in POSTMAN and SOAP UI,

When content type = "application/x-www-form-urlencoded"
and request body should be is, for Ex:
"xml_data=<Data xmlns="http://j2ee.netbeans.org/xsd/Target"> <Header xmlns=""> <DocumentVersion>1.0</DocumentVersion> <MessageId>str1234</MessageId> </Header> </Data>"
Its successfully processing.

But in REST parameter i tried concatenating as String/hard code (for Ex: "xml_data=<Data xmlns="http://j2ee.netbeans.org/xsd/Target"> <Header xmlns=""> <DocumentVersion>1.0</DocumentVersion> <MessageId>str1234</MessageId> </Header> </Data>") and send as REST parameter value throwing error.
I also tried creating 2 parts for REST one for "xml_data" and another for "<Data xmlns="http://j2ee.netbeans.org/xsd/Target"> <Header xmlns=""> <DocumentVersion>1.0</DocumentVersion> <MessageId>str1234</MessageId> </Header> </Data>"
throwing error.


Formatting and sending message in REST Adapter/WSDL is an issue or missed something ?

Any suggestion ?

REST WSDL format:
------------------------------------------------------------
<definitions name="Rest_WSDL"
    targetNamespace="http://j2ee.netbeans.org/wsdl/PO_Header/src/Rest_WSDL"
    xmlns="http://schemas.xmlsoap.org/wsdl/"
    xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
    xmlns:mime="http://schemas.xmlsoap.org/wsdl/mime/"
    xmlns:xsd="http://www.w3.org/2001/XMLSchema"
    xmlns:rest="http://schemas.sun.com/jbi/wsdl-extensions/rest/"
    xmlns:plnk="http://docs.oasis-open.org/wsbpel/2.0/plnktype" xmlns:tns="http://j2ee.netbeans.org/wsdl/PO_Header/src/Rest_WSDL" xmlns:ns0="http://j2ee.netbeans.org/xsd/Target" xmlns:ns1="http://xml.netbeans.org/schema/input" xmlns:ns2="http://xml.netbeans.org/schema/root">
    <types>
        <xsd:schema targetNamespace="http://j2ee.netbeans.org/wsdl/PO_Header/src/Rest_WSDL">
            <xsd:import namespace="http://j2ee.netbeans.org/xsd/Target" schemaLocation="Target.xsd"/>
            <xsd:import namespace="http://xml.netbeans.org/schema/input" schemaLocation="input.xsd"/>
            <xsd:import namespace="http://xml.netbeans.org/schema/root" schemaLocation="root.xsd"/>
        </xsd:schema>
    </types>
    <message name="Rest_Call_PostRequest">
        <part name="Data" type="xsd:anyType"/>
       
    </message>
    <message name="Rest_Call_PostResponse">
        <part name="part1" type="xsd:anyType"/>
    </message>
    <portType name="RestOutboundPortType">
        <operation name="Rest_Call_Post">
            <input name="Rest_Call_PostInput" xmlns:tns="http://j2ee.netbeans.org/wsdl/PO_Header/src/Rest_WSDL" message="tns:Rest_Call_PostRequest"/>
            <output name="Rest_Call_PostOutput" xmlns:tns="http://j2ee.netbeans.org/wsdl/PO_Header/src/Rest_WSDL" message="tns:Rest_Call_PostResponse"/>
        </operation>
    </portType>
    <binding name="RestOutboundBinding" type="tns:RestOutboundPortType">
        <rest:binding/>
        <operation name="Rest_Call_Post">
            <rest:operation>
<![CDATA[
# required, URL of external resource
# for example: http://somehost.com/users/{id}/address
url=URL

# optional, HTTP verb to access the resource, defaults to GET
method=POST

# optional, acceptable media types of response can be added as array elements in JSON format
accept-types=[ "application/xml" ]

# optional, preferred natural languages for the response, added as array elements in JSON format
accept-languages=[ ]

# optional, content type of outgoing payload, defaults to any type
content-type=application/x-www-form-urlencoded

# optional, additional custom HTTP headers can be added as pairs in JSON format in this property
# for example:  { "authorization" : "257984234", "last-modifed" : "2009-04-23:12:00:00" }
headers={ }

# optional, style for the parameters, valid values are QUERY, MATRIX, defaults to QUERY
param-style=Query

# optional, additional custom HTTP parameters can be added as pairs in JSON format in this property
# for example:  { "userid" : "abc" , "userpassword" : "123" }
params={ }

# optional, adding HTTP Basic Authentication header to the HTTP request,
# if the two properties below are specified
basic-auth-username=XXXXXXX
basic-auth-password=YYYYYYY

]]></rest:operation>
            <input name="Rest_Call_PostInput">
                <mime:content part="Rest_Call_PostRequest" type="application/x-www-form-urlencoded"/>
            </input>
            <output name="Rest_Call_PostOutput"/>
        </operation>
    </binding>
    <service name="RestOutboundService">
        <port name="RestOutboundWSDL_OutboundPort" binding="tns:RestOutboundBinding">
            <rest:address/>
        </port>
    </service>
    <plnk:partnerLinkType name="RestOutboundWSDL">
       
        <plnk:role name="RestOutboundPortTypeRole" portType="tns:RestOutboundPortType"/>
    </plnk:partnerLinkType>
</definitions>


Regards,
Sri


If you reply to this email, your message will be added to the discussion below:

http://openesb-community-forum.794670.n2.nabble.com/How-to-Post-Map-Message-to-Rest-HTTP-Post-URL-tp7581614p7581621.html

To start a new topic under OpenESB Community Forum, email [hidden email]
To unsubscribe from OpenESB Community Forum, click here.
NAML

Loading...