cancel
Showing results for 
Search instead for 
Did you mean: 

SAP Java Connector: XML parser error on returned complex type

Former Member
0 Kudos

I am doing an RFC using SAP Jco and am getting an JCO_ERRORS_XML_PARSER error on a return (exported) parameter. The parameter is complex and contains nested tables.

The function XMLReaderBase.parse() is raising the error saying the XML is malformed. It says its 'expecting < instead of 3'. But I don't think this is the case. In the trace file and in the debugger, I can see the entire XML string and it looks OK.

I think the problem is that the parser is only getting part of the XML string. It is getting only the first 5652 characters (not bytes).

Is there some buffer or line length limit that controls the parser?

Any help is appreciated. Thanks.

--

Tim

Accepted Solutions (0)

Answers (6)

Answers (6)

Former Member
0 Kudos

Resolved...

<a href="https://service.sap.com/sap/support/notes/105400">SAP Note 105400 - XML parser error in RFC with Jco or .NET connector</a>

--

Tim

Former Member
0 Kudos

From SAP TechSupport...

<i>We identified the bug responsible for that misbehavior and are currently working on a fix. I think that we will be able to deliver it next week.

JCo is interpreting the RFC data correctly by throwing this XML Parser exception. So unfortunately it will be a SAP application server side fix for creating and sending a valid RFC data stream.</i>

--

Tim

Former Member
0 Kudos

Here is sample Java that causes the error. You should only need to set up the createClient() parameters for your user and system. The rest should work.

Can anybody else run it successfully or not?



import java.text.NumberFormat;
import java.util.Calendar;

import com.sap.mw.jco.*;

/*
 You can set the following JVM args to control debugging/tracing:

 -Djco.trace_level=0 -Djrfc.trace=0 -Djco.trace_path=somedirectory
*/

public class TmpTutorialConnect extends Object
{
	public TmpTutorialConnect()
	{
		try
		{			
			JCO.Client myConnection = JCO.createClient(
					"800",     // SAP client number
					"userid",  // user account name
					"pwd",     // password
					"EN",      // language
					"apphost", // 
					"systemno" // something like 00 or 01
					);
			myConnection.connect();
			System.out.println(""+myConnection.getAttributes());
			
			IRepository myRepository = JCO.createRepository("MyRepository", myConnection);			
						
			NumberFormat yf = NumberFormat.getInstance();
			yf.setMinimumIntegerDigits(4);
			yf.setGroupingUsed(false);
			
			NumberFormat mf = NumberFormat.getInstance();
			mf.setMinimumIntegerDigits(2);
			
			NumberFormat df = NumberFormat.getInstance();
			df.setMinimumIntegerDigits(2);
			
			String today;			
			{
				Calendar ctoday = Calendar.getInstance();
				
				int y = ctoday.get(Calendar.YEAR);
				int m = ctoday.get(Calendar.MONTH);
				int d = ctoday.get(Calendar.DAY_OF_MONTH);
				
				today = yf.format(y)+mf.format(m+1)+df.format(d);
			}

			final String READ_START_DATE = today;
			final String READ_START_TIME = "00:00:00";
			final String READ_END_DATE   = today;
			final String READ_END_TIME   = "06:00:00";
			
			IFunctionTemplate ftemplate = myRepository.getFunctionTemplate("SWNC_GET_STATRECS_FRAME");
			if(ftemplate != null) 
			{
				JCO.Function function = ftemplate.getFunction();
				JCO.ParameterList input = function.getImportParameterList();

				input.setValue(READ_START_DATE, "READ_START_DATE");
				input.setValue(READ_START_TIME, "READ_START_TIME");
				input.setValue(READ_END_DATE, "READ_END_DATE");				
				input.setValue(READ_END_TIME, "READ_END_TIME");
				
				// This dies with a truncated XML exception JCO_ERROR_XML_PARSER if any data
				// is returned (if the date is old enough, there is no data, and empty tables
				// are returned successfully). The stack trace is at the end of this file.

				myConnection.execute(function);
			}

			myConnection.disconnect();
		}
		catch (Exception ex)
		{
			ex.printStackTrace();
			System.exit(1);
		}
	}

	public static void main(String args[])
	{
		TmpTutorialConnect app = new TmpTutorialConnect();
	}
}

Former Member
0 Kudos

Again, I'm thinking this may be some kind of Windows buffering issue. The client is running Windows XP Pro 2002 SP2.

I can see the returned XML in the Jco trace files. I can copy/paste it into a text file and it displays OK in Internet Explorer. So SAP is returning valid XML.

When I look at the file in emacs and remove the newlines, emacs displays only part of the file. It displays exactly the same number of characters that the JCo parse routine is given, 5652 characters.

An aside: Is this the forum to be asking about stand-alone JCo issues? If not, which one?

Thanks.

--

Tim

Former Member
0 Kudos

Oh, and I'm using JCo 2.1.8.

--

Tim

Former Member
0 Kudos

Bump.

I'm calling the NetWeaver (Basis 700) functions to get STAD and ST03 information:

SWNC_GET_STATRECS_FRAME - to get stat recs

SWNC_GET_AGGREGATES_FRAME - to get aggregate information

Has anybody had success calling these fuctions via the RFC interface, either from within SAP in ABAP or from externally using JCo or JCA?

Thanks.

--

Tim