on 07-18-2011 7:58 AM
Dear all,
i have a custom java mapping, in which i thorw a StreamTransformationException when an error
occurs.
However, whereas in SXMB_MONI i trace the exception like this:
cvc-maxLength-valid: Value 'fewfwffewfewfwefewfwefw' with length = '23' is not facet-valid with respect to maxLength '15' for type 'null'
in SOAPUI i only get this truncated message:
<SOAP:Envelope xmlns:SOAP="http://schemas.xmlsoap.org/soap/envelope/">
<SOAP:Body>
<SOAP:Fault>
<faultcode>SOAP:Server</faultcode>
<faultstring>System Error</faultstring>
<detail>
<s:SystemError xmlns:s="http://sap.com/xi/WebService/xi2.0">
<context></context>
<code>MAPPING.STREAM_TRANSFORMATION_EX</code>
<text>*Vom Anwendungs-Mappingprogramm com/xxx/pi/mapping/validation/CustomValida~ wurde eine StreamTransformationException ausgelöst. cvc-maxLength-valid: Value '22307555555' with len~</*text>
</s:SystemError>
</detail>
</SOAP:Fault>
</SOAP:Body>
</SOAP:Envelope>
Is there a trick to get the whole message ? What length has the field ?
Hi Jan,
I could not get the meaning of custom java mapping. Now you need to find out the reason of such exception. Here a certain field length is exceeding its maximum value. Maybe the field name is "CVC". Now here is what you can do. Find out the field name for which the exception is being thrown. From sxmb_moni you need to find out the field name which has value 'fewfwffewfewfwefewfwefw'. Now within java mapping program I expect some statements like this
if(fieldname.length()>maxLength)
{
throw new StreamTransformationException("value "+ fieldname+" with length="+fieldname.length()+" is not facet-valid with respect to maxLength "+maxlength+" for type null");
}
Your java mapping program is doing validation on incoming XML message and throwing exception if some field is not meeting the expectations. Thus you need a change in code so that Exceptions are not thrown for failing in validations( instead you can have few more lines of reasons of error at end of target xml).
regards
Anupam
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
my mapping shoud be used purely for xml validation. My code looks like this:
try {
SAXSource source = new SAXSource(new InputSource(insr));
validator.validate(source);
} catch (Exception e) {
String trace = e.getMessage();
getTrace().addInfo(trace); // write to SXMB_MONI
throw new StreamTransformationException(trace, e.getCause()); //write to sender / Exception
As you see i am passing directly the e.getMessage() into the StreamTransformationException.
The first excerpt from my post results from the statement "getTrace().addInfo(trace)" and is shown in SXMB_MONI.
The second excerpt is in my SOAPFault - PI is writing the "Vom Anwendungs-Mappingprogramm com/xxx/pi/mapping/validation/CustomValida~ wurde eine StreamTransformationException ausgelöst." in front of it.
So basically, as opposed to having a static error message as in your example - this should work. Or is there a lenght restriction of the element ?
Hi Jan,
Look at this line of code "validator.validate(source);" . validator is an instance of an class. Find out the coding for the class. Here you are expected to find the code i mentioned in my earlier post. There within the code find the portion which deals with the field length validation. You need to alter the code such that throwing of exception is prevented.
"getTrace().addInfo(trace)" -
> writing message to sxmb_moni
Here problem is after java mapping program executes properly and completely, your source message flows to target xml.
Now whenever there is an exception, the mapping program stops execution, at that point as far as I can make out from the code.
You need to ensure the program is not stopped in middle due to length restriction and target xml is formed. Your writing to sxmb_moni or to SOAP fault will not solve the problem. For this try reading the code for class of "validator" and change it to prevent throwing of exceptions.
regards
Anupam
Edited by: anupamsap on Jul 20, 2011 4:01 PM
Hi,
perhaps a little more background:
This mapping is used in the request message. It should stop message mapping, because incoming xml is not valid.
validator is an instance of javax.xml.validation.Validator class and it should do - validation of incoming xml on
the basis of an xsd.
I simply want to return the error message of the validator.validate() method to the sender.
Therefore, if an error in validation occurrs, because incoming xml is not valid, i throw a StreamTransformationException to signal that message mapping is unsuccessful. I have to ensure that invalid xml is not forwarded to the receiver. Thats the point of validation. The length restriction is there because it has to be there. If i enter a value that is too long, ultimately the receiver will have a problem with that.
Additionally, because i have a synchronous scenario i inform the sender of the error.
I hope you understand my intention better now.
Hi Jan,
Please look into the part where Exception is being thrown within the class of validator. Now you are getting the error message as
<text>*Vom Anwendungs-Mappingprogramm com/xxx/pi/mapping/validation/CustomValida~ wurde eine StreamTransformationException ausgelöst. _cvc-maxLength-valid: Value '22307555555' with len_~</*text>
Now this is a system thrown message "cvc-maxLength-valid: Value '22307555555' with len". You can modify the message being shown here using the code I showed in my first post, so that the cause of error is clearly known. The element does not have a fixed length. So you can alter it according to your message. Now to do this you must know the exact cause of throwing an exception. Thus this line
throw new StreamTransformationException(trace, e.getCause()); will show your message instead of that by the system (system messages are not always meaningful)
This requires modification of the java mapping code within class of validator.
regards
Anupam
Understood your problem. your throw validation exception during java mapping. You see truncated fault message in the SOAPUI? Is that right? This is internal log trace design of SOAPUI. If you want meaningful entire fault message to transmit, I would recommend to construct three message structures. Already you are constructing request and response. If you do validation in mapping then your target structure is fault message structure. Then you can show your entire validation message in both sxmb_moni and SOAP UI.
Please refer these links for meaningful validation fault messages to send to clients.
http://help.sap.com/saphelp_nwpi711/helpdata/en/48/5946db5f693912e10000000a42189b/content.htm
/people/jin.shin/blog/2007/05/21/handling-web-service-soap-fault-responses-in-sap-netweaver-xi
/people/shabarish.vijayakumar/blog/2006/11/02/fault-message-types--a-demo-part-1
No one has had a similar problem during Java message mapping ?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
84 | |
25 | |
12 | |
9 | |
7 | |
6 | |
5 | |
5 | |
4 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.