Author |
Message
|
rhine |
Posted: Wed Dec 02, 2015 4:27 am Post subject: HTTP Request Issues |
|
|
Novice
Joined: 17 Nov 2015 Posts: 16
|
I'm getting a http 500 error when I do a request to a WebService.
I’ve checked that on traces.
I receive an hexadecimal from the server which translated says:
Code: |
<?xml version="1.0" encoding="utf-8"?><soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"><soapenv:Body><soapenv:Fault><faultcode></faultcode><faultstring>javax.xml.stream.XMLStreamException: The root element is required in a well-formed document.</faultstring><detail></detail></soapenv:Fault></soapenv:Body></soapenv:Envelope> |
Root element is required in a well-formed document.
Apparently this happens when the message is not being built properly, but the message I send is exactly as the message I send from SoapUI. And it does exactly what i want it to do.
I'm building the whole request in a compute node, and then using a HTTP Request node.
These are REQ and RESP traces:
Code: |
(0x01000000:Name):HTTPRequestHeader = ( ['WSREQHDR' : 0x4ff936a0]
(0x03000000:NameValue):Content-Length = '0' (CHARACTER)
(0x03000000:NameValue):Host = '**.**.**.*:****' (CHARACTER)
(0x03000000:NameValue):Content-Type = 'text/xml; charset=utf-8' (CHARACTER)
(0x03000000:NameValue):Accept = 'application/soap+xml, application/dime, multipart/relate, text/*' (CHARACTER)
(0x03000000:NameValue):X-Original-HTTP-URL = 'https://*******/wisd/WebServices/WebService' (CHARACTER)
(0x03000000:NameValue):SOAPAction = '""' (CHARACTER)
)
(0x01000000:Name):HTTPResponseHeader = ( ['WSRSPHDR' : 0x4ff92750]
(0x03000000:NameValue):X-Original-HTTP-Status-Line = 'HTTP/1.0 500 Internal Server Error' (CHARACTER)
(0x03000000:NameValue):X-Original-HTTP-Status-Code = 500 (INTEGER)
(0x03000000:NameValue):X-Powered-By = 'Servlet/3.0' (CHARACTER)
(0x03000000:NameValue):Content-Type = 'text/xml; charset=utf-8' (CHARACTER)
(0x03000000:NameValue):Content-Language = 'en-US' (CHARACTER)
(0x03000000:NameValue):Content-Length = '352' (CHARACTER)
(0x03000000:NameValue):Date = 'Wed, 02 Dec 2015 11:36:10 GMT' (CHARACTER) |
I did try to use SOAP nodes but I had some issues with WSDL file. This is just another old fashioned way to do it but it should also work. |
|
Back to top |
|
 |
Vitor |
Posted: Wed Dec 02, 2015 6:31 am Post subject: Re: HTTP Request Issues |
|
|
 Grand High Poobah
Joined: 11 Nov 2005 Posts: 26093 Location: Texas, USA
|
rhine wrote: |
I did try to use SOAP nodes but I had some issues with WSDL file. |
What issues? Could this not be a cause of the problem?
rhine wrote: |
Apparently this happens when the message is not being built properly, but the message I send is exactly as the message I send from SoapUI. |
The server you're calling begs to differ, and I don't see anything in what you've posted that shows you providing a well-formed XML document wrapped in a SOAP Envelope. _________________ Honesty is the best policy.
Insanity is the best defence. |
|
Back to top |
|
 |
rhine |
Posted: Wed Dec 02, 2015 6:52 am Post subject: |
|
|
Novice
Joined: 17 Nov 2015 Posts: 16
|
This is the code within the compute node where is build the request:
Code: |
BROKER SCHEMA BrokerSchema
CREATE COMPUTE MODULE Flow_Start_Tfr_WS_Crt_Msg_Pet_WS
DECLARE ID_CMD_REQ_CRT EXTERNAL CHAR '';
CREATE FUNCTION Main() RETURNS BOOLEAN
BEGIN
-- CALL CopyMessageHeaders();
CALL CopyEntireMessage();
SET OutputLocalEnvironment = InputLocalEnvironment;
CALL CrtMsgPet();
RETURN TRUE;
END;
CREATE PROCEDURE CopyMessageHeaders() BEGIN
DECLARE I INTEGER 1;
DECLARE J INTEGER;
SET J = CARDINALITY(InputRoot.*[]);
WHILE I < J DO
SET OutputRoot.*[I] = InputRoot.*[I];
SET I = I + 1;
END WHILE;
END;
CREATE PROCEDURE CopyEntireMessage() BEGIN
SET OutputRoot = InputRoot;
END;
CREATE PROCEDURE CrtMsgPet()
BEGIN
DECLARE STRURL CHAR;
DECLARE POSINI INTEGER;
DECLARE POSFIN INTEGER;
DECLARE POSFIN2 INTEGER;
DECLARE IDHOST CHAR;
DECLARE soapmsg CHAR;
DECLARE IDCOMP CHAR;
DECLARE IDFILE CHAR;
DECLARE IDSTRDATE CHAR;
DECLARE IDENDDATE CHAR;
SET IDCOMP = 'US12';
SET IDFILE = 'GR';
SET IDSTRDATE = '20150512';
SET IDENDDATE = '20150512';
SET STRURL = ID_CMD_REQ_CRT;
SET POSINI = POSITION('/' IN STRURL FROM 1 REPEAT 2);
SET POSFIN = POSITION('/' IN STRURL FROM POSINI + 1);
SET IDHOST = TRIM(SUBSTRING(STRURL FROM POSINI + 1 FOR (POSFIN - POSINI - 1)));
SET soapmsg = '<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:soap="http://WebService.WebServices.isd.ibm.com/soapoverhttp/">' ||
'<soapenv:Header/><soapenv:Body><soap:WebServiceName><cod_file>' || IDFILE || '</cod_file>'||
'<cod_company>' || IDCOMP || '</cod_company><ip_delta_load>0</ip_delta_load><ini_date>' || IDSTRDATE || '</ini_date>' ||
'<end_date>' || IDENDDATE || '</end_date><current_date>20151202</current_date><current_time>100010</current_time>' ||
'</soap:WebServiceName></soapenv:Body></soapenv:Envelope>';
SET OutputRoot.BLOB.BLOB = CAST(soapmsg AS BLOB CCSID 1208);
SET OutputRoot.HTTPRequestHeader.Host = IDHOST;
SET OutputRoot.HTTPRequestHeader."Content-Type" = 'text/xml; charset=utf-8';
SET OutputRoot.HTTPRequestHeader."Content-Length" = LENGTH(CAST("OutputRoot"."BLOB"."BLOB" AS BLOB CCSID 1208));
SET OutputRoot.HTTPRequestHeader."Content-Language" = 'en-US';
SET OutputRoot.HTTPRequestHeader.Accept = 'application/soap+xml, application/dime, multipart/relate, text/*';
SET OutputLocalEnvironment.Destination.HTTP.RequestURL = ID_CMD_REQ_CRT;
SET OutputRoot.HTTPRequestHeader."X-Original-HTTP-URL" = 'https://**.**.**.*:****/wisd/WebServices/WebService';
SET OutputRoot.HTTPRequestHeader."SOAPAction"= '""';
--SET OutputRoot.HTTPRequestHeader."SOAPAction"= '';
SET OutputLocalEnvironment.Destination.HTTP.RequestLine.Method = 'POST';
END;
END MODULE;
|
I've realized that in the traces after the HTTP Request node I 've got Content-Length = '0' even hardcoding a length:
Code: |
(0x01000000:Name):HTTPRequestHeader = ( ['WSREQHDR' : 0x4ff90ed0]
(0x03000000:NameValue):Content-Length = '0' (CHARACTER)
(0x03000000:NameValue):Host = '******:****' (CHARACTER)
(0x03000000:NameValue):Content-Type = 'text/xml; charset=utf-8' (CHARACTER)
(0x03000000:NameValue):Content-Language = 'en-US' (CHARACTER)
(0x03000000:NameValue):Accept = 'application/soap+xml, application/dime, multipart/relate, text/*' (CHARACTER)
(0x03000000:NameValue):X-Original-HTTP-URL = 'https://****wisd/WebServices/WebService' (CHARACTER)
(0x03000000:NameValue):SOAPAction = '""' (CHARACTER)
(0x03000000:NameValue):Connection = 'Keep-Alive' (CHARACTER)
)
(0x01000000:Name):HTTPResponseHeader = ( ['WSRSPHDR' : 0x4ff914f0]
(0x03000000:NameValue):X-Original-HTTP-Status-Line = 'HTTP/1.1 500 Internal Server Error' (CHARACTER)
(0x03000000:NameValue):X-Original-HTTP-Status-Code = 500 (INTEGER)
(0x03000000:NameValue):X-Powered-By = 'Servlet/3.0' (CHARACTER)
(0x03000000:NameValue):Content-Type = 'text/xml; charset=utf-8' (CHARACTER)
(0x03000000:NameValue):Content-Language = 'en-US' (CHARACTER)
(0x03000000:NameValue):Content-Length = '352' (CHARACTER)
(0x03000000:NameValue):Connection = 'Close' (CHARACTER)
(0x03000000:NameValue):Date = 'Wed, 02 Dec 2015 14:34:11 GMT' (CHARACTER)
) |
|
|
Back to top |
|
 |
smdavies99 |
Posted: Wed Dec 02, 2015 6:58 am Post subject: |
|
|
 Jedi Council
Joined: 10 Feb 2003 Posts: 6076 Location: Somewhere over the Rainbow this side of Never-never land.
|
As you are sending a request to a webservice why do you think you need BOTH HTTP headers? _________________ WMQ User since 1999
MQSI/WBI/WMB/'Thingy' User since 2002
Linux user since 1995
Every time you reinvent the wheel the more square it gets (anon). If in doubt think and investigate before you ask silly questions. |
|
Back to top |
|
 |
timber |
Posted: Wed Dec 02, 2015 7:02 am Post subject: |
|
|
 Grand Master
Joined: 25 Aug 2015 Posts: 1292
|
This is unusual:
Code: |
SET soapmsg = '<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:soap="http://WebService.WebServices.isd.ibm.com/soapoverhttp/">' ||
'<soapenv:Header/><soapenv:Body><soap:WebServiceName><cod_file>' || IDFILE || '</cod_file>'||
'<cod_company>' || IDCOMP || '</cod_company><ip_delta_load>0</ip_delta_load><ini_date>' || IDSTRDATE || '</ini_date>' ||
'<end_date>' || IDENDDATE || '</end_date><current_date>20151202</current_date><current_time>100010</current_time>' ||
'</soap:WebServiceName></soapenv:Body></soapenv:Envelope>'; |
Is there a reason why you are building your XML request using string concatenation? Most people would build an XMLNSC tree and then call ASBITSTREAM to obtain the BLOB. |
|
Back to top |
|
 |
rhine |
Posted: Wed Dec 02, 2015 7:36 am Post subject: |
|
|
Novice
Joined: 17 Nov 2015 Posts: 16
|
timber wrote: |
This is unusual:
Code: |
SET soapmsg = '<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:soap="http://WebService.WebServices.isd.ibm.com/soapoverhttp/">' ||
'<soapenv:Header/><soapenv:Body><soap:WebServiceName><cod_file>' || IDFILE || '</cod_file>'||
'<cod_company>' || IDCOMP || '</cod_company><ip_delta_load>0</ip_delta_load><ini_date>' || IDSTRDATE || '</ini_date>' ||
'<end_date>' || IDENDDATE || '</end_date><current_date>20151202</current_date><current_time>100010</current_time>' ||
'</soap:WebServiceName></soapenv:Body></soapenv:Envelope>'; |
Is there a reason why you are building your XML request using string concatenation? Most people would build an XMLNSC tree and then call ASBITSTREAM to obtain the BLOB. |
Newbieness and lack of experience. I take pieces of information to make my flow work. It doesnt look like the best way, thats for sure; anyway, in traces i can see that the BLOB message i build is correct. I can see very long piece of Hexadecimal here:
Code: |
(0x01000000:Name):BLOB = ( ['none' : 0x5520e0e0]
(0x03000000:NameValue):BLOB = 'Giant HEXADECIMAL here' (BLOB)
) |
Which in the common language means:
Code: |
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:soap="http://WebService.WebServices.isd.ibm.com/soapoverhttp/">
<soapenv:Header/>
<soapenv:Body>
<soap:WebServiceName>
<cod_file>GR</cod_file>
<cod_company>US12</cod_company>
<ip_delta_load>0</ip_delta_load>
<ini_date>20150512</ini_date>
<end_date>20150512</end_date>
<current_date>20151202</current_date>
<current_time>100010</current_time>
</soap:WebServiceName>
</soapenv:Body>
</soapenv:Envelope> |
|
|
Back to top |
|
 |
mgk |
Posted: Wed Dec 02, 2015 8:15 am Post subject: |
|
|
 Padawan
Joined: 31 Jul 2003 Posts: 1642
|
So you also need to create the Body (you BLOB in this case) at the END of the message, after you create the headers as the message tree is build in the order of your statements... _________________ MGK
The postings I make on this site are my own and don't necessarily represent IBM's positions, strategies or opinions. |
|
Back to top |
|
 |
timber |
Posted: Wed Dec 02, 2015 9:10 am Post subject: |
|
|
 Grand Master
Joined: 25 Aug 2015 Posts: 1292
|
I recommend that you
- review the samples that are supplied with the product. They will show you how to construct a SOAP message tree.
- revisit your decision to abandon the use of of the SOAPRequest node. If you had a problem with the WSDL, why not quote the error here? Someone else may be able to get you over that problem. |
|
Back to top |
|
 |
rhine |
Posted: Wed Dec 02, 2015 9:16 am Post subject: |
|
|
Novice
Joined: 17 Nov 2015 Posts: 16
|
mgk wrote: |
So you also need to create the Body (you BLOB in this case) at the END of the message, after you create the headers as the message tree is build in the order of your statements... |
Ok, that was the problem. Thank you very much mgk |
|
Back to top |
|
 |
|