Hi folks,
I been asked to post data from a form to a msg broker system being tested by an external team. I have been told that all I should do is post the data using http request in the following format to a server.
var http =new HttpClient();
var url="http://P510-4.nottscc.gov.uk:7080/FOI";
http.contentType = "'text/xml'";
http.requestHeader = ["SOAPAction", '""'];
http.postData ='<?xml version="1.0" encoding="UTF-8" ?>';
http.postData +='<?XML:NAMESPACE PREFIX = SOAPENV /><SOAPENV:ENVELOPE xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">';
http.postData +='<SOAPENV:BODY>';
http.postData +='<?XML:NAMESPACE PREFIX = NS0 /><NS0:SETFOIDATA xmlns:ns0="urn:WSDL5">';
http.postData +='<NEWFOIREQUEST>';
http.postData +='';
http.postData +='<FNAME>'+firstname+'</FNAME>';
http.postData +='<LNAME>'+surname+'</LNAME>';
http.postData +=' '+address+'';
http.postData +='<COUNTY>'+county+'</COUNTY>';
http.postData +='<POSTCODE>'+postcode+'</POSTCODE>';
http.postData +='<EMAILADDRESS>'+emailaddress+'</EMAILADDRESS>';
http.postData +='<TELNO>'+telno+'</TELNO>';
http.postData +='<REQUESTDETAILS>'+requestdetails+'</REQUESTDETAILS>';
http.postData +='<REQUESTREFNO>'+requestRef+'</REQUESTREFNO>';
http.postData +='<SUBMITTEDDATE>'+entryDate+'</SUBMITTEDDATE>';
http.postData +='</NEWFOIREQUEST>';
http.postData +='</NS0:SETFOIDATA>';
http.postData +='</SOAPENV:BODY>';
http.postData +='</SOAPENV:ENVELOPE>';
//http.postData = escape(http.postData);
var sendMyRequest = http.sendRequest(url);
it posts but breaks off after the first line of the post data
I've tried posting as he says (see below - the variables are from request strings from the form) but it doesn't accept it.
var http =new HttpClient();
var url="<A href="http://p510-4.nottscc.gov.uk:7080/FOI">http://P510-4.nottscc.gov.uk:7080/FOI</A>";
http.contentType = "'text/xml'";
http.requestHeader = ["SOAPAction", '"<A href="http://p510-4.nottscc.gov.uk:7080/FOI"'">http://P510-4.nottscc.gov.uk:7080/FOI"'</A>];
var postForm = '';
postForm ='<?xml version="1.0" encoding="UTF-8" ?>';
postForm +='<soapenv:Envelope xmlns:soapenv="<A href="http://schemas.xmlsoap.org/soap/envelope/">http://schemas.xmlsoap.org/soap/envelope/</A>" xmlns:xsd="<A href="http://www.w3.org/2001/XMLSchema">http://www.w3.org/2001/XMLSchema</A>" xmlns:xsi="<A href="http://www.w3.org/2001/XMLSchema-instance">'">http://www.w3.org/2001/XMLSchema-instance">'</A>;
postForm +='<soapenv:Body>';
postForm +='<ns0:setFOIData xmlns:ns0="urn:WSDL5">';
postForm +='<newFOIRequest>';
postForm +='<title>'+titleStr+'</title>';
postForm +='<fname>'+firstname+'</fname>';
postForm +='<lname>'+surname+'</lname>';
postForm +='<address>'+address+'</address>';
postForm +='<county>'+county+'</county>';
postForm +='<postcode>'+postcode+'</postcode>';
postForm +='<emailAddress>'+emailaddress+'</emailAddress>';
postForm +='<telNo>'+telno+'</telNo>';
postForm +='<requestDetails>'+requestdetails+'</requestDetails>';
postForm +='<requestRefNo>'+requestRef+'</requestRefNo>';
postForm +='<SubmittedDate>'+entryDate+'</SubmittedDate>';
postForm +='</newFOIRequest>';
postForm +='</ns0:setFOIData>';
postForm +='</soapenv:Body>';
postForm +='</soapenv:Envelope>';
http.postData = postForm;</P>
<P>var sendMyRequest = http.sendRequest(url);
Can anyone tell me why this does not work please. I am fairly new to XML and would appreciate any help.
Thanks
Enter your message below
Sign in or Join us (it's free).