HTTP POST with XML with HTTPService
Hi,
I need to be able to send an HTTP POST request to a server I
have on Tomcat. In the body of the POST Request I need to have the
following:
<setView domain="someDomain" view="macro" />
We have tried the following using the HTTPService, but with
no such luck
<mx:HTTPService id="setViewHTTPService" url="{serverURL}"
resultFormat="object" contentType="application/xml"
method="POST">
<mx:request>
<setView domain="abc" view="xyz" />
</mx:request>
</mx:HTTPService>
Is there a way for us to specify the body of the HTTP Post
using HTTPService, or a different class for that matter.
var variables:URLVariables = new
URLVariables("name=Franklin");
//or variables.name = "Franklin";
var request:URLRequest = new URLRequest();
request.url = "
http://www.[yourdomain
request.method = URLRequestMethod.POST;
request.data = variables;
var loader:URLLoader = new URLLoader();
loader.dataFormat = URLLoaderDataFormat.VARIABLES;
loader.addEventListener(Event.COMPLETE, completeHandler);
try
loader.load(request);
catch (error:Error)
trace("Unable to load URL");
function completeHandler(event:Event):void
trace(event.target.data.welcomeMessage);
This is in the help documentation and what I generally use.
Similar Messages
-
Configure HTTP POST on arrowpoint with version 5.00
I configured the headers rule for http post but it´s doesn´t work.
Someone have any idea..??
This is the config.....thanks
service wqa01-27
ip address 172.16.51.27
keepalive uri "/newadmin/admin/arrow.asp"
keepalive frequency 35
keepalive type http
string wqa0127
active
service wqa02-27
keepalive uri "/newadmin/admin/arrow.asp"
keepalive frequency 35
keepalive type http
string wqa0227
ip address 172.16.52.27
active
content ar-qa-post
vip address 200.41.112.38
protocol tcp
port 80
url "/*"
advanced-balance arrowpoint-cookie
arrowpoint-cookie advanced
header-field-rule POST-METHOD weight 0
add service wqa01-27
add service wqa02-27
active
!********************* HEADER FIELD GROUP *********************
header-field-group GET-METHOD
header-field GET request-line contain "GET"
header-field-group POST-METHOD
header-field POST request-line contain "POST"Javier,
I would suggest you to start with something basic and than add complexity.
Create a very simple content rule with just an ip address. no port. no protocol.
Then add one or more servers.
Activate.
Give it a try like this.
Does it work ?
If yes, define 'protocol tcp' and 'port 80'.
Does it work ?
If yes, configure 'url "/*"'
does it work ?
If yes, configure 'advanced-balance arrowpointcookie'
This config is explained at
http://www.cisco.com/en/US/products/hw/contnetw/ps789/products_tech_note09186a0080094398.shtml
It it does not work, tell us what is not working.
Is it the stickyness that does not work or you can't even connect to the vip address ?
Also collect a sniffer trace on client and server.
Thanks,
Gilles. -
CL_HTTP_CLIENT, HTTP POST of XML as a form field, encoding
I am working on a couple of interfaces between a SAPsystem (NetWeaver 2004s, ABAP stack) and another system.
On the SAP side we are using the built-in HTTP-client (CL_HTTP_CLIENT).
For the interface from SAP to the other system, the other system expects an XML as the value of a form field in an HTTP POST request.
In fact, it was described as doing the equivalent to this HTML-fragment in a web-browser:
<form action="http://over.there.com/interface/import.php" method="post">
<p>Please enter your xml data:
<textarea name="data" cols="50" rows="10"></textarea>
<input type="submit" value="submit">
</p>
</form>
I assume I will have to do a SET_METHOD in order to get the POST method (as opposed to GET) and a SET_FORM_FIELD (for field "data").
According to the reference I found at W3C ( http://www.w3.org/TR/html4/interact/forms.html ), the default encoding method for a POST is "application/x-www-form-urlencoded". Does this mean I have to do this encoding myself?
Could I opt for another encoding - "text/xml" for example? If so, how? With a SET_HEADER_FIELD?Thank you.
This is how we set the context-type:
call method client->request->if_http_entity~set_content_type
exporting
content_type = p_contyp.
where p_contyp contained 'text/xml'.
This is how we set the form-field data:
call method client->request->if_http_entity~set_form_field
exporting
name = p_formfd
value = xmlstring.
where p_formfd contained 'data' - the name that was specified.
This is how we make the request a POST:
call method client->request->set_method
exporting
method = 'POST'. -
How to config receiver http adapter for HTTP POST without XML tags ??
Hi All,
Can you please provide some infornation on How to config receiver http adapter for HTTP POST (Request) without XML tags ?? Our receiving product doesn't support XML formats.
Is there any option to bypass server authentication on the XI?
If anybody has the same experience or know how to please provide inputs.
Thanx
NavinHi,
you can use xsl mapping for this in which u xtract
the contents only but not the xml tag.
Ranjit -
I am trying to emulate a webpage that is POSTing info to a URL which is a JSP that also has parameters in the URL. I am having problems getting my java code to emulate doing this task manually through a web browser.
The webpage has the following HTML code:
<form method=post action=hello.jsp?y=60245&x=698>
<input type="text" name="name" value="jim">
<input type=submit name=submit value="Now">
</form>
...notice that the jsp referenced above has some parameters appended to the url, but the method is post.
Here's my code to try to do the same thing as if I manually pressed the submit button in a browser:
URL url = new URL("hello.jsp?y=60245&x=698");
httpConnection = (HttpURLConnection)url.openConnection();
httpConnection.setRequestMethod("POST");
httpConnection.setDoOutput(true);
httpConnection.setDoInput(true);
httpConnection.setUseCaches(false);
httpConnection.setRequestProperty("Content-Type", "application/x-www-form-urlencoded");
DataOutputStream output = new DataOutputStream(httpConnection.getOutputStream());
output.writeBytes("name=jim&submit=Now");
output.flush();
BufferedReader is = new BufferedReader(new InputStreamReader(httpConnection.getInputStream()));
Writer w = new BufferedWriter(new FileWriter("CapturedHTML.html"));
int data=0,count=0;
while(data!=-1){
data = is.read();
w.write(data);
count++;
System.out.println(count + " bytes read");
w.flush();
w.close();
is.close();
output.close();I write out the result to a file so that I can see the HTML returned by the JSP. It's a completely different webpage than if I were to have manually clicked the submit button on a browser.
WHY???????? How is a browser actually sending the info to the jsp when it has info both in its URL and in the post data?I might be wrong, but the browser could have some sort of mechanism built into it which makes sure that the parameters appended to the url are actually passed as a part of a POST requst, while a Java program might not pass them at all.
Have you tried passing these params: y=60245&x=698 as a part of a POST request, rather than adding them to the URL.
Also, how do u know which response from JSP is correct? They might be different but do u know which one is the correct one? Do you know what the response should look like? that would make things a lot easier as u could figure out what parameters are causing the differences in the responses u r getting. -
How to HTTP-Post different XML messages to one receiving URL on XI side?
Hi
I have a problem with a HTTP => XI => IDoc scenario.
A client want to send 4 different XML documents to only 1 receiving URL on the XI side. How can I handle this in XI???
To send XML data via HTTP to XI you have to specify the namespace, interface and service in the URL. But I only can specify 1 namespace, interface and namespace in the URL...
But how can I define a generic message interface for all 4 messages.
The solution with 4 receiving URL's is easy, but not workable for the client
Thx
manukuYou can do following:
Create an interface with an artificial root node like this:
root
- structure message 1
- structure message 2
- structure message 3
A simple XSLT/Java mapping adds that root node to every message.
Create different mappings based on the structure if the different mappings and do routing based on the same.
Another option: Upgrade to PI 7.1. Here you can simply create a service interface with different operations and routing/mapping based on the operations.
Regards
Stefan -
Persisting unexplained errors when parsing XML with schema validation
Hi,
I am trying to parse an XML file including XML schema validation. When I validate my .xml and .xsd in NetBeans 5.5 beta, I get not error. When I parse my XML in Java, I systematically get the following errors no matter what I try:
i) Document root element "SQL_STATEMENT_LIST", must match DOCTYPE root "null".
ii) Document is invalid: no grammar found.
The code I use is the following:
try {
Document document;
DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
factory.setValidating(true);
factory.setNamespaceAware(true);
DocumentBuilder builder = factory.newDocumentBuilder();
document = builder.parse( new File(PathToXml) );
My XML is:
<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
<!-- Defining the SQL_STATEMENT_LIST element -->
<xs:element name="SQL_STATEMENT_LIST" type= "SQL_STATEMENT_ITEM"/>
<xs:complexType name="SQL_STATEMENT_ITEM">
<xs:sequence>
<xs:element name="SQL_SCRIPT" minOccurs="0" maxOccurs="unbounded"/>
</xs:sequence>
</xs:complexType>
<!-- Defining simple type ApplicationType with 3 possible values -->
<xs:simpleType name="ApplicationType">
<xs:restriction base="xs:string">
<xs:enumeration value="DawningStreams"/>
<xs:enumeration value="BaseResilience"/>
<xs:enumeration value="BackBone"/>
</xs:restriction>
</xs:simpleType>
<!-- Defining the SQL_SCRIPT element -->
<xs:element name="SQL_SCRIPT" type= "SQL_STATEMENT"/>
<xs:complexType name="SQL_STATEMENT">
<xs:sequence>
<xs:element name="NAME" type="xs:string"/>
<xs:element name="TYPE" type="xs:string"/>
<xs:element name="APPLICATION" type="ApplicationType"/>
<xs:element name="SCRIPT" type="xs:string"/>
<!-- Making sure the following element can occurs any number of times -->
<xs:element name="FOLLOWS" type="xs:string" minOccurs="0" maxOccurs="unbounded"/>
</xs:sequence>
</xs:complexType>
</xs:schema>
and my XML is:
<?xml version="1.0" encoding="UTF-8"?>
<!--
Document : SQLStatements.xml
Created on : 1 juillet 2006, 15:08
Author : J�r�me Verstrynge
Description:
Purpose of the document follows.
-->
<SQL_STATEMENT_LIST xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="http://www.dawningstreams.com/XML-Schemas/SQLStatements.xsd">
<SQL_SCRIPT>
<NAME>CREATE_PEERS_TABLE</NAME>
<TYPE>CREATION</TYPE>
<APPLICATION>DawningStreams</APPLICATION>
<SCRIPT>
CREATE CACHED TABLE PEERS (
PEER_ID VARCHAR(20) NOT NULL,
PEER_KNOWN_AS VARCHAR(30) DEFAULT ' ' ,
PRIMARY KEY ( PEER_ID )
</SCRIPT>
</SQL_SCRIPT>
<SQL_SCRIPT>
<NAME>CREATE_COMMUNITIES_TABLE</NAME>
<TYPE>CREATION</TYPE>
<APPLICATION>DawningStreams</APPLICATION>
<SCRIPT>
CREATE CACHED TABLE COMMUNITIES (
COMMUNITY_ID VARCHAR(20) NOT NULL,
COMMUNITY_KNOWN_AS VARCHAR(25) DEFAULT ' ',
PRIMARY KEY ( COMMUNITY_ID )
</SCRIPT>
</SQL_SCRIPT>
<SQL_SCRIPT>
<NAME>CREATE_COMMUNITY_MEMBERS_TABLE</NAME>
<TYPE>CREATION</TYPE>
<APPLICATION>DawningStreams</APPLICATION>
<SCRIPT>
CREATE CACHED TABLE COMMUNITY_MEMBERS (
COMMUNITY_ID VARCHAR(20) NOT NULL,
PEER_ID VARCHAR(20) NOT NULL,
PRIMARY KEY ( COMMUNITY_ID, PEER_ID )
</SCRIPT>
</SQL_SCRIPT>
<SQL_SCRIPT>
<NAME>DROP_PEER_TABLE</NAME>
<TYPE>DELETION</TYPE>
<APPLICATION>DawningStreams</APPLICATION>
<SCRIPT>
DROP TABLE PEERS IF EXISTS
</SCRIPT>
</SQL_SCRIPT>
<SQL_SCRIPT>
<NAME>DROP_COMMUNITIES_TABLE</NAME>
<TYPE>DELETION</TYPE>
<APPLICATION>DawningStreams</APPLICATION>
<SCRIPT>
DROP TABLE COMMUNITIES IF EXISTS
</SCRIPT>
</SQL_SCRIPT>
<SQL_SCRIPT>
<NAME>DROP_COMMUNITY_MEMBERS_TABLE</NAME>
<TYPE>DELETION</TYPE>
<APPLICATION>DawningStreams</APPLICATION>
<SCRIPT>
DROP TABLE COMMUNITY_MEMBERS IF EXISTS
</SCRIPT>
</SQL_SCRIPT>
<SQL_SCRIPT>
<NAME>CREATE_COMMUNITY_MEMBERS_VIEW</NAME>
<TYPE>CREATION</TYPE>
<APPLICATION>DawningStreams</APPLICATION>
<SCRIPT>
CREATE VIEW COMMUNITY_MEMBERS_VW AS
SELECT P.PEER_ID, P.PEER_KNOWN_AS, C.COMMUNITY_ID, C.COMMUNITY_KNOWN_AS
FROM PEERS P, COMMUNITIES C, COMMUNITY_MEMBERS CM
WHERE P.PEER_ID = CM.PEER_ID
AND C.COMMUNITY_ID = CM.COMMUNITY_ID
</SCRIPT>
<FOLLOWS>CREATE_PEERS_TABLE</FOLLOWS>
<FOLLOWS>CREATE_COMMUNITIES_TABLE</FOLLOWS>
</SQL_SCRIPT>
</SQL_STATEMENT_LIST>
Any ideas? Thanks !!!
J�r�me VerstryngeHi,
I found the solution in the following post:
Validate xml with DOM - no grammar found
Sep 17, 2003 10:58 AM
The solution is to add a line of code when parsing:
try {
Document document;
DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
factory.setValidating(true);
factory.setNamespaceAware(true);
factory.setAttribute("http://java.sun.com/xml/jaxp/properties/schemaLanguage", "http://www.w3.org/2001/XMLSchema");
DocumentBuilder builder = factory.newDocumentBuilder();
document = builder.parse( new File(PathToXml) );
The errors are gone !!!
J�r�me Verstrynge -
How to send te XML data using HTTPS post call & receiving response in ML
ur present design does the HTTP post for XML data using PL/SQL stored procedure call to a Java program embedded in Oracle database as Oracle Java Stored procedure. The limitation with this is that we are able to do HTTP post; but with HTTPS post; we are not able to achieve because of certificates are not installed on Oracle database.
we fiond that the certificates need to be installed on Oracle apps server; not on database server. As we have to go ultimately with HTTPS post in Production environment; we are planning to shift this part of program(sending XML through HTTPS post call & receiving response in middle layer-Apps server in this case).
how i can do this plz give some solutionIf you can make the source app to an HTTP Post to the Oracle XML DB repository, and POST contains a schema based XML document you can use a trigger on the default table to validate the XML that is posted. The return message would need to be managed using a database trigger. You could raise an HTTP error which the source App would trap....
-
How to Invoke service using HTTP POST in BPEL?
I have a client using .net service with a web page http://.../httpreceive.aspx which is invoke through an http post. How can we post xml message using http post to the url in BPEL. Are there any documentation on doing this? Will this require writing a java class to do an http post the xml message to the url?
Edited by: sns724 on Feb 12, 2009 11:56 AMI created a wsdl with the http-binding to do a HTTP Post and I'm getting a com.collaxa.cube.ws.wsif.providers.http.WSIFOperation_HTTP@1ac9964 : Could not invoke 'process'; nested exception is: java.lang.NullPointerException.
Here's my wsdl with the binding:
<definitions name="TestHTTPost" targetNamespace="http://test.com"
xmlns="http://schemas.xmlsoap.org/wsdl/"
xmlns:tns="http://test.com"
xmlns:http="http://schemas.xmlsoap.org/wsdl/http/"
xmlns:mime="http://schemas.xmlsoap.org/wsdl/mime/"
xmlns:soap12="http://schemas.xmlsoap.org/wsdl/soap12/"
xmlns:plnk="http://schemas.xmlsoap.org/ws/2003/05/partner-link/"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/">
<types>
<schema attributeFormDefault="qualified" elementFormDefault="qualified"
targetNamespace="http://hyphen.com"
xmlns="http://www.w3.org/2001/XMLSchema">
<element name="AddressBookEntry">
<complexType>
<sequence>
<element name="AddressBookNumber" type="string"/>
<element name="Name" type="string"/>
<element name="AddressLine1" type="string"/>
<element name="AddressLine2" type="string"/>
<element name="City" type="string"/>
<element name="State" type="string"/>
<element name="PostalCode" type="string"/>
<element name="Phone" type="string"/>
<element name="Fax" type="string"/>
<element name="Email" type="string"/>
<element name="ElectDest" type="string"/>
</sequence>
</complexType>
</element>
<element name="PostMessageResult">
<complexType>
<sequence>
<element name="Result" type="string"/>
<element name="Errors">
<complexType>
<sequence>
<element name="Error">
<complexType>
<sequence>
<element name="ErrorDescription" type="string"/>
<element name="ErrorSource" type="string"/>
</sequence>
</complexType>
</element>
</sequence>
</complexType>
</element>
</sequence>
</complexType>
</element>
</schema>
</types>
<message name="HTTPPostServiceRequestMessage">
<part name="payload" element="tns:AddressBookEntry"/>
</message>
<message name="HTTPPostServiceResponseMessage">
<part name="payload" element="tns:PostMessageResult"/>
</message>
<portType name="HTTPPostService">
<operation name="process">
<input message="tns:HTTPPostServiceRequestMessage" />
<output message="tns:HTTPPostServiceResponseMessage"/>
</operation>
</portType>
<binding name="HTTPPost" type="tns:HTTPPostService">
<http:binding verb="POST"/>
<operation name="process">
<http:operation location="/httpreceive.aspx"/>
<input>
<mime:mimeXml part="payload"/>
<mime:content type="text/xml"/>
</input>
<output>
<mime:mimeXml part="payload"/>
<mime:content type="text/xml"/>
</output>
</operation>
</binding>
<service name="HTTPPostService">
<port name="HTTPPost" binding="tns:HTTPPost">
<http:address location="https://testxml.solutions.com"/>
</port>
</service>
<!-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
PARTNER LINK TYPE DEFINITION
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -->
<plnk:partnerLinkType name="HTTPPostService">
<plnk:role name="HTTPPostServiceProvider">
<plnk:portType name="tns:HTTPPostService"/>
</plnk:role>
</plnk:partnerLinkType>
</definitions> -
Hello,
I just have a simple question. In my Flex program, I am trying to find a way to listen for an incoming HTTP POST message - something with functionality similar to that of the HttpListener class in C#. I have not been able to find anything at all to help with this though, would anyone know of something like this?
Thanks.My Flex program subscribes to changes that occur in a program on remote server. The change notifications are sent back to my client in the form of an HTTP Post message. The Flex program needs to be able to detect when these Posts are received.
-
HTTP POST Request with XML file in
Hi @ all,
I would like to send an HTTP Request with an XML File in the body to an SAP System
I have the target URL and the a XML File.
Now the question is. Is it possible to use something like the HTTP_POST FuBa to send an url post request with an xml file?
If yes can anybody give me a hint?
I have a php script which exactly do this coding. But to integrate it all in one system it is necessary to transform it into ABAP and call it there.
// compose url and request and call send function
function test($productID, $categoryID) {
// create url
$PIhost = "XXX.wdf.sap.corp";
$PIport = "50080";
$PIurl = "/sap/xi/adapter_plain";
$PIurl .= "?sap-client=800";
$PIurl .= "&service=XXX";
$PIurl .= "&namespace=XXX";
$PIurl .= "&interface=Frontend_Interface";
$PIurl .= "&qos=EO";
$PIurl .= "&sap-user=XXX";
$PIurl .= "&sap-password=XXX";
// create xml
$request = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n";
$request .="<n1:FrontendInbound_MessageType xmlns:n1=\"http://crmpiebay.com\">\n";
$request .= "\t<FrontendInbound>\n";
$request .= "\t\t<ProductName/>\n";
$request .= "\t\t<ProductCategory>".$categoryID."</ProductCategory>\n";
$request .= "\t\t<ProductID>".$productID."</ProductID>\n";
$request .= "\t\t<MessageID/>\n";
$request .= "\t</FrontendInbound>\n";
$request .= "</n1:FrontendInbound_MessageType>";
// send http request
postToHost($PIhost, $PIport, $PIurl, $_SERVER["SERVER_NAME"].":".$_SERVER["SERVER_PORT"]."/".$_SERVER["PHP_SELF"], $request);
// send post request to PI server
function postToHost($host, $port, $path, $referer, $data_to_send) {
$fp = fsockopen($host, $port);
if($fp) {
$res="";
fputs($fp, "POST $path HTTP/1.1\r\n");
fputs($fp, "Host: $host\r\n");
fputs($fp, "Referer: $referer\r\n");
fputs($fp, "Content-type: text/plain\r\n");
fputs($fp, "Content-length: ". strlen($data_to_send) ."\r\n");
fputs($fp, "Connection: close\r\n\r\n");
fputs($fp, $data_to_send);
while(!feof($fp)) {
$res .= fgets($fp, 128);
fclose($fp);
return $res;
Would be great if anybody could give me a hint how to solve such a HTTP Post request with XML body data.
Thanks in advance.
Chris
Edited by: Christian Kuehne on Feb 26, 2009 4:32 PMhi friend could you please share your solution regarding this query if u got it already?
-
How would I do a http post with a xml file
How would I do a http post with a xml file.
I have a url called https://localhost:8443/wss/WSS and the XML file is sent as part of the HTTP POST body.
How would I send this XML file when posting?most people just add feedback to the comments they've asked about already, rather than ignoring all the feedback and making a new post with the exact same information:
http://forum.java.sun.com/thread.jspa?threadID=5247331&messageID=10020973#10020973
If you want to add in an XML file to a POST command, you'd add it just like any other file you'd attach to a post request, especially (if you're request is the same as your last post) if you're just doing a jsp page. I'd do it something like this:
<form method=POST ENCTYPE="multipart/form-data" action="https://rcpdm.mnb.gd-ais.com/Windchill/servlet/IE/tasks/DJK/fcsAddContentComplete.xml">
<H3> File Name </H3>
<input type=file name=filename>
<input type=submit value="Do it!">
</form>Then again, this solution has literally nothing to do with java, and you still need to make sure that your servlet knows what to actually do with that information you're sending it. -
HTTPService POST with XML does not declare charset encoding
Hi all.
I'm trying to do a HTTP POST of some XML using HTTPService
and I've got it working apart form the fact that the HTTP message
sent does no declare what charcater set it is using for encoding.
As a test I send a 'ñ' character and it seems from the
resultant bytes that the charset being used is UTF-8.
My ActionScript is...
var xml:XML=new XML(<root/>);
xml.@testCharacter="ñ";
xml.appendChild(<login/>);
xml.login.@username="bob";
xml.login.@password="secret";
var httpService:HTTPService=new HTTPService();
httpService.url='
http://app.localhost/null';
httpService.method="POST";
httpService.contentType=HTTPService.CONTENT_TYPE_XML;
httpService.request=xml;
httpService.send();
And what seems to get sent over the wire is (shown in
8bit-ASCII)...
POST /null HTTP/1.1
Host: app.localhost
User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US;
rv:1.8.1.7) Gecko/20070914 Firefox/2.0.0.7
Accept:
text/xml,application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,image/png ,*/*;q=0.5
Accept-Language: en,en-us;q=0.7,en-gb;q=0.3
Accept-Encoding: gzip,deflate
Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7
Keep-Alive: 300
Connection: keep-alive
Content-type: application/xml
Content-length: 77
<root testCharacter="A±">
<login username="bob" password="secret"/>
</root>
Anyone know (1) how I can control what character set gets
used for encoding and (2) how I can get either XML or HTTPService
to declare what the encoding is?
Thanks in advance, Neil.Jarod,
XML parser product managers who might be able to help you on a parser-specific issue like this "hang out" here on OTN in the XML forum. Have you tried posting there to catch their attention? Thanks. -
Using perl with the HTTP POST method to exchange XML with the Auth service
Has anyone written a perl script to do this yet?
I've been trying all day and keep getting "Content is not allowed in prolog.
I've used the example xml from the docs
<?xml version="1.0" encoding="UTF-8"?>
<AuthContext version="1.0">
<Request authIdentifier="0">
<NewAuthContext orgName="dc=exampleorg,dc=com">
</NewAuthContext>
</Request>
</AuthContext>
Then I read the python post at http://swforum.sun.com/jive/thread.jspa?forumID=79&threadID=22370
and the error changed to Premature end of file.
this is the portion of perl that is getting the error:
use strict;
use LWP::UserAgent;
use HTTP::Request::Common;
my $browser = LWP::UserAgent->new(agent => 'xml client');
my $greeting = <<GREETING;
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<RequestSet vers="1.0" svcid="auth" reqid="1">
<Request>
<![CDATA[<?xml version="1.0" encoding="UTF-8"?>
<AuthContext version="1.0">
<Request authIdentifier="0">
<NewAuthContext orgName="dc=belo,dc=com">
</NewAuthContext>
</Request>
</AuthContext>]]></Request>
</RequestSet>
GREETING
my $response = $browser->request(POST 'http://idpoc1.test.belo.com/amserver/authservice',
Content_Type => 'text/xml',
Content => [xmlRequest => $greeting]
print $response->error_as_HTML unless $response->is_success;Your problem seems to lie in the build of the request. Here you use the "sample=$data" which will invalidate the XML itself. I've tested your code changing only the build of the Request and this works fine! Given an XML like this :
<?xml version="1.0" encoding="ISO-8859-1"?>
<data>
<txnInfo sourcePartnerCode="6" txnDate="2005.09.08"/>
<unitOfWorkInfo sourceTicketID="SourceTicket_1" diaryEntry="Diray_1" Status="Status_OK"/>
</data>
The Server Stub should look like this :
#!/usr/bin/perl
use XML::Simple;
use Data::Dumper;
print qq{Content-type: text/xml\n\n};
if($ENV{'REQUEST_METHOD'} eq "GET"){
$my_data = $ENV{'QUERY_STRING'};
print "jfghdsfjghsdg$my_data";
} else {
$data_length = $ENV{'CONTENT_LENGTH'};
$bytes_read = read(STDIN, $my_data, $data_length);
print "$bytes_read, $my_data";
$xml = new XML::Simple (KeyAttr=>[]);
print "have passed XML::Simple creation\n";
$data = $xml->XMLin("$my_data");
print "i want to be here \n";
$transcode=$data->{txnInfo}->{sourcePartnerCode};
#print "$data->{txnInfo}->{sourcePartnerCode}";
print $transcode;
CASE: {
($transcode==6) && do {
print "i am here";
$lstmoddat=$data->{txnInfo}->{txnDate};
$srctktid=$data->{unitOfWorkInfo}->{sourceTicketID};
$actvtylogdesc=$data->{unitOfWorkInfo}->{diaryEntry};
$status=$data->{unitOfWorkInfo}->{Status};
$command='bop_cmd -f update1.frg "upd_stats("""Administrator""","""'.$srctktid.'""","""FIP""","""what is this???""")"';
print "$lstmoddat $srctktid $status \n";
print "$command";
system("$command");
print "i am done";
last CASE;
And the client stub should look like this :
use LWP::UserAgent;
use HTTP::Request;
use IO;
#use XML::Writer;
my $ua = LWP::UserAgent->new(env_proxy => 1, keep_alive => 1, timeout => 30, );
open INPUT, "<AcceptIncident.xml";
my @greeting = <INPUT>; #-- Read file containing XML struct to send
print "Hello World\n";
my $data_to_send; #-- And build a string of it
foreach my $newItem (@greeting) {
$data_to_send = "$data_to_send$newItem";
print "Sending \n";
my $head = HTTP::Headers->new(Content_Type => "text/xml", "ID" => "sample");
my $req = HTTP::Request->new('POST', 'http://matrix/cgi-bin/test1.pl', $head, "$data_to_send");
my $response = $ua->request($req);
print $response->as_string; Also you should make sure you have both HTTP::Request amd XML::Simple installed, orelse this will not work.
Hope this is of some help to you. -
How to get HTTP Post body with text/xml
There is a HTTP Post like this from a client:
POST http://local:8080/test HTTP/1.1
Content-Type: text/xml
Content-Length: 210
<?xml version="1.0" encoding="UTF-8"?>
<CancelOrders>
<Cancel>
<ItemID>898980</ItemID>
<UserName>REM</UserName>
<DateTime>11/10/2003 06:33:33</DateTime>
</Cancel>
</CancelOrders>
I need to get the content of the xml through servlet.
What can I do?
Please helpCan you put some Duke points here, you might get a response sooner.
Maybe you are looking for
-
How to print header in first and last page only in SAPSCRIPT
Hi! How to print header in first and last page only in SAPSCRIPT, in between pages, I need to print all line items in MAIN window only . Thanks in anticipation! Aki.
-
I HAVE BEEN USING PDF FILES FOR TWENTY YEARS. YESTERSAY I COULD NOT ACCESS ANY OF THE PDF 100.000 FILES. MOST OF THE FILES ARE LOCATED IN FOLDERS. THE ADOBE MESSAGE BOX STATES.. "NOT SUPPORTED OR DAMAGED" THE SAME IS TRUE WITH MY WORD DOCS I RAN T
-
All my file type associations work fine. Every image opens in Photoshop CC 2014. No problem there. But when I make a droplet I do have a problem. The droplet opens Photoshop CC (not 2014) and my actions fail because that is a Dutch version of Photosh
-
HT1296 my device is not showing up in itunes when I connect it with cable
My iphone 5 does not appear as 'device' when I connect to itunes using usb cable. Does anyone know why this has suddenly started happening? At the same time as this started I also started getting a message on my phone asking me to 'trust' or 'don't
-
Will a ipod nano charger work with a new ipod touch?
will a ipod nano charger work with a new ipod touch?