Connecting to Analysis Services with Java XML

Tech Tip: Click here to run a free scan for Windows Errors and optimize PC performance



I know this has been posted before but I cannot seem to find an answer to
my problem. Basically I am having trouble with the connection string in
"DataSourceInfo". I get the error:

XA:XMLAnalysisError.88BA0500
Unable to process the request, because the DataSourceInfo property was
missing or not correctly specified

I can get the VB sample to work no problem but for some reason I just
cannot get Java to work. I know I should not be using hard-coded
parameters but I am just trying to get it to work and they are the same I
am using in the VB example.

My Java code is:

import java.net.*;
import java.util.*;
import org.apache.soap.*;
import org.apache.soap.rpc.*;
import org.apache.soap.encoding.*;
import org.apache.soap.encoding.soapenc.*; import
org.apache.soap.util.xml.*;
import org.apache.soap.transport.http.*;

public class Client {

public static void main( String[] args ) throws Exception {

URL url = new URL("http://192.168.2.106/xmla/msxisapi.dll";;

SOAPMappingRegistry smr = new SOAPMappingRegistry();
StringDeserializer sd = new StringDeserializer();
smr.mapTypes(Constants.NS_URI_SOAP_ENC,
new QName("","Result"), null, null, sd);

SOAPHTTPConnection st = new SOAPHTTPConnection();

Call call = new Call();
call.setSOAPTransport(st);
call.setSOAPMappingRegistry(smr);

call.setTargetObjectURI
("urn:schemas-microsoft-com:xml-analysis");
call.setMethodName("Discover");
call.setEncodingStyleURI("http://schemas.xmlsoap.org/soap/encoding/";);

Vector params = new Vector();

params.addElement(new Parameter("RequestType",String.class,
"MDSCHEMA_CUBES", null));

params.addElement(new Parameter("Restrictions",String.class,
"<RestrictionList>" +
"<DataSourceName>" +
"Local Analysis Server" +
"</DataSourceName>" +

"<CATALOG_NAME>" +
"FoodMart" +
"</CATALOG_NAME>" +
"</RestrictionList>", null ));

params.addElement(new Parameter("Properties",String.class,
"<PropertyList>" +
"<DataSourceInfo>" +
"Data Source=server1;Provider=MSOLAP.2" +
"</DataSourceInfo>" +

"<Catalog>" +
"Foodmart" +
"</Catalog>" +
"</PropertyList>", null ));


call.setParams(params);
call.buildEnvelope();

System.out.println("Request="+call.toString()+"\n");

Response resp = null;
try {
resp = call.invoke (url,
"urn:schemas-microsoft-com:xml-analysis:Discover");
}
catch (SOAPException e) {
System.err.println("Caught SOAPException(" +
e.getFaultCode() + "): " +
e.getMessage ());
return;
}

if (resp != null && !resp.generatedFault()) {
Parameter ret = resp.getReturnValue();
Object value = ret.getValue();

System.out.println("Answer="+value);
}
else {
Fault fault = resp.getFault();
System.out.println("Generated Fault:");
System.out.println("Fault code = "+fault.getFaultCode());
System.out.println("Fault string = "+fault.getFaultString());
}
}
}

Anyone any ideas?

Thanks.
.