Skip to content

Commit d8a0b35

Browse files
committed
fix Power BI xml response
Signed-off-by: dbulahov <[email protected]>
1 parent 4ca341c commit d8a0b35

File tree

3 files changed

+41
-32
lines changed

3 files changed

+41
-32
lines changed

server/adapter.soapmessage/src/main/java/org/eclipse/daanse/xmla/server/adapter/soapmessage/Constants.java

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -29,14 +29,14 @@ static class MSXMLA {
2929

3030
public static final QName QN_COMMAND = new QName(NS_URN, "Command", PREFIX);
3131
public static final QName QN_DISCOVER = new QName(NS_URN, "Discover", PREFIX);
32-
public static final QName QN_DISCOVER_RESPONSE = new QName(NS_URN, "DiscoverResponse", PREFIX);
32+
public static final QName QN_DISCOVER_RESPONSE = new QName(NS_URN, "DiscoverResponse", "");
3333
public static final QName QN_EXECUTE = new QName(NS_URN, "Execute", PREFIX);
34-
public static final QName QN_EXECUTE_RESPONSE = new QName(NS_URN, "ExecuteResponse", PREFIX);
34+
public static final QName QN_EXECUTE_RESPONSE = new QName(NS_URN, "ExecuteResponse", "");
3535
public static final QName QN_PROPERTIES = new QName(NS_URN, "Properties", PREFIX);
3636
public static final QName QN_PROPERTY_LIST = new QName(NS_URN, "PropertyList", PREFIX);
3737
public static final QName QN_RESTRICTIONS = new QName(NS_URN, "Restrictions", PREFIX);
3838
public static final QName QN_RESTRICTION_LIST = new QName(NS_URN, "RestrictionList", PREFIX);
39-
public static final QName QN_RETURN = new QName(NS_URN, "return", PREFIX);
39+
public static final QName QN_RETURN = new QName(NS_URN, "return", "");
4040
public static final QName QN_REQUEST_TYPE = new QName(NS_URN, "RequestType", PREFIX);
4141

4242
}
@@ -52,9 +52,9 @@ static class EMPTY {
5252
/////
5353
static class ROWSET {
5454

55-
public static final String PREFIX = "rowset";
55+
public static final String PREFIX = "";
5656
public static final String NS_URN = "urn:schemas-microsoft-com:xml-analysis:rowset";
57-
public static final QName QN_ROOT = new QName(ROWSET.NS_URN, "root", ROWSET.PREFIX);
57+
public static final QName QN_ROOT = new QName(ROWSET.NS_URN, "root", "");
5858
public static final QName QN_ROW = new QName(ROWSET.NS_URN, "row", ROWSET.PREFIX);
5959

6060
static class ROW_PROPERTY {
@@ -823,7 +823,7 @@ static class ROW_PROPERTY {
823823
/////
824824

825825
static class MDDATASET {
826-
public static final String PREFIX = "mddataset";
826+
public static final String PREFIX = "";
827827
public static final String NS_URN = "urn:schemas-microsoft-com:xml-analysis:mddataset";
828828
public static final QName QN_CELL_INFO = new QName(MDDATASET.NS_URN, "CellInfo", MDDATASET.PREFIX);
829829
public static final QName QN_OLAP_INFO = new QName(MDDATASET.NS_URN, "OlapInfo", MDDATASET.PREFIX);

server/adapter.soapmessage/src/main/java/org/eclipse/daanse/xmla/server/adapter/soapmessage/SoapUtil.java

Lines changed: 24 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -361,6 +361,7 @@
361361
import org.eclipse.daanse.xmla.api.msxmla.NormTuplesType;
362362
import org.eclipse.daanse.xmla.api.xmla.Restriction;
363363
import org.eclipse.daanse.xmla.api.xmla_empty.Emptyresult;
364+
import org.eclipse.daanse.xmla.server.adapter.soapmessage.Constants.XSD;
364365
import org.slf4j.Logger;
365366
import org.slf4j.LoggerFactory;
366367

@@ -1794,9 +1795,12 @@ private static SOAPElement addDiscoverRowSetsRoot(SOAPElement body) throws SOAPE
17941795
private static SOAPElement addDiscoverPropertiesRoot(SOAPElement body) throws SOAPException {
17951796
SOAPElement seRoot = prepareRootElement(body);
17961797
seRoot.setAttribute("xmlns:xsi", Constants.XSI.NS_URN);
1797-
seRoot.setAttribute("xmlns:xsd", Constants.XSD.NS_URN);
1798-
seRoot.setAttribute("xmlns:msxmla", "http://schemas.microsoft.com/analysisservices/2003/xmla");
1798+
seRoot.setAttribute("xmlns", "urn:schemas-microsoft-com:xml-analysis:rowset");
1799+
seRoot.setAttribute("xmlns:EX", "urn:schemas-microsoft-com:xml-analysis:exception");
17991800
SOAPElement schema = addChildElement(seRoot, Constants.XSD.QN_SCHEMA);
1801+
schema.setAttribute("xmlns:xsd", "http://www.w3.org/2001/XMLSchema");
1802+
schema.setAttribute("xmlns:xsi", "http://www.w3.org/2001/XMLSchema-instance");
1803+
schema.setAttribute("xmlns", "urn:schemas-microsoft-com:xml-analysis:rowset");
18001804
schema.setAttribute("targetNamespace", Constants.ROWSET.NS_URN);
18011805
schema.setAttribute("xmlns:sql", Constants.SQL.NS_URN);
18021806
schema.setAttribute("elementFormDefault", "qualified");
@@ -1817,13 +1821,13 @@ private static SOAPElement addDiscoverPropertiesRoot(SOAPElement body) throws SO
18171821
SOAPElement p = addChildElement(r, Constants.XSD.QN_PATTERN);
18181822
p.setAttribute("value", UUID_VALUE);
18191823

1820-
SOAPElement ct1 = addChildElement(schema, Constants.XSD.QN_COMPLEX_TYPE);
1821-
ct1.setAttribute("name", "xmlDocument");
1822-
SOAPElement s1 = addChildElement(ct1, Constants.XSD.QN_SEQUENCE);
1823-
SOAPElement a = addChildElement(s1, Constants.XSD.QN_ANY);
1824+
//0SOAPElement ct1 = addChildElement(schema, Constants.XSD.QN_COMPLEX_TYPE);
1825+
//ct1.setAttribute("name", "xmlDocument");
1826+
//SOAPElement s1 = addChildElement(ct1, Constants.XSD.QN_SEQUENCE);
1827+
//SOAPElement a = addChildElement(s1, Constants.XSD.QN_ANY);
18241828

18251829
SOAPElement ct2 = addChildElement(schema, Constants.XSD.QN_COMPLEX_TYPE);
1826-
ct1.setAttribute("name", "row");
1830+
ct2.setAttribute("name", "row");
18271831
SOAPElement s2 = addChildElement(ct2, Constants.XSD.QN_SEQUENCE);
18281832
SOAPElement s2e1 = addChildElement(s2, Constants.XSD.QN_ELEMENT);
18291833
s2e1.setAttribute("sql:field", "PropertyName");
@@ -1834,13 +1838,13 @@ private static SOAPElement addDiscoverPropertiesRoot(SOAPElement body) throws SO
18341838
s2e2.setAttribute("sql:field", "PropertyDescription");
18351839
s2e2.setAttribute("name", "PropertyDescription");
18361840
s2e2.setAttribute("type", "xsd:string");
1837-
s2e2.setAttribute("minOccurs", "0");
1841+
//s2e2.setAttribute("minOccurs", "0");
18381842

18391843
SOAPElement s2e3 = addChildElement(s2, Constants.XSD.QN_ELEMENT);
18401844
s2e3.setAttribute("sql:field", "PropertyType");
18411845
s2e3.setAttribute("name", "PropertyType");
18421846
s2e3.setAttribute("type", "xsd:string");
1843-
s2e3.setAttribute("minOccurs", "0");
1847+
//s2e3.setAttribute("minOccurs", "0");
18441848

18451849
SOAPElement s2e4 = addChildElement(s2, Constants.XSD.QN_ELEMENT);
18461850
s2e4.setAttribute("sql:field", "PropertyAccessType");
@@ -1851,13 +1855,13 @@ private static SOAPElement addDiscoverPropertiesRoot(SOAPElement body) throws SO
18511855
s2e5.setAttribute("sql:field", "IsRequired");
18521856
s2e5.setAttribute("name", "IsRequired");
18531857
s2e5.setAttribute("type", "xsd:boolean");
1854-
s2e5.setAttribute("minOccurs", "0");
1858+
//s2e5.setAttribute("minOccurs", "0");
18551859

18561860
SOAPElement s2e6 = addChildElement(s2, Constants.XSD.QN_ELEMENT);
18571861
s2e6.setAttribute("sql:field", "Value");
18581862
s2e6.setAttribute("name", "Value");
18591863
s2e6.setAttribute("type", "xsd:string");
1860-
s2e6.setAttribute("minOccurs", "0");
1864+
//s2e6.setAttribute("minOccurs", "0");
18611865

18621866
return seRoot;
18631867
}
@@ -2538,12 +2542,13 @@ private static SOAPElement addDiscoverDataSourcesRoot(SOAPBody body) throws SOAP
25382542
SOAPElement schema = fillRoot(seRoot);
25392543

25402544
SOAPElement s = prepareSequenceElement(schema);
2541-
addElement(s, "LiteralName", "xsd:string", null);
2542-
addElement(s, "LiteralValue", "xsd:string", "0");
2543-
addElement(s, "LiteralInvalidChars", "xsd:string", "0");
2544-
addElement(s, "LiteralInvalidStartingChars", "xsd:string", "0");
2545-
addElement(s, "LiteralMaxLength", "xsd:int", "0");
2546-
addElement(s, "LiteralNameEnumValue", "xsd:int", "0");
2545+
addElement(s, "DataSourceName", "xsd:string", null);
2546+
addElement(s, "DataSourceDescription", "xsd:string", "0");
2547+
addElement(s, "URL", "xsd:string", "0");
2548+
addElement(s, "DataSourceInfo", "xsd:string", "0");
2549+
addElement(s, "ProviderName", "xsd:string", "0");
2550+
addElement(s, "ProviderType", "xsd:string", "0");
2551+
addElement(s, "AuthenticationMode", "xsd:string", null);
25472552
return seRoot;
25482553
}
25492554

@@ -2597,7 +2602,7 @@ private static void addElement(SOAPElement s, String name, String type, String m
25972602

25982603
private static SOAPElement fillRoot(SOAPElement root) {
25992604
root.setAttribute("xmlns:xsi", Constants.XSI.NS_URN);
2600-
root.setAttribute("xmlns:xsd", Constants.XSD.NS_URN);
2605+
//root.setAttribute("xmlns:xsd", Constants.XSD.NS_URN);
26012606
root.setAttribute("xmlns:EX", Constants.EX.NS_URN);
26022607
SOAPElement schema = addChildElement(root, Constants.XSD.QN_SCHEMA);
26032608
schema.setAttribute("xmlns:xsd", Constants.XSD.NS_URN);
@@ -2685,7 +2690,7 @@ private static void addRowsetSchema(SOAPElement root, RowSet rowSet) {
26852690
simpleType.setAttribute("name", "uuid");
26862691
SOAPElement restriction = addChildElement(simpleType, Constants.XSD.QN_RESTRICTION);
26872692
restriction.setAttribute("base", "xsd:string");
2688-
SOAPElement pattern = addChildElement(restriction, Constants.XSD.QN_RESTRICTION);
2693+
SOAPElement pattern = addChildElement(restriction, Constants.XSD.QN_PATTERN);
26892694
pattern.setAttribute("value", UUID_VALUE);
26902695

26912696
SOAPElement ct = addChildElement(schema, Constants.XSD.QN_COMPLEX_TYPE);

server/adapter.soapmessage/src/main/java/org/eclipse/daanse/xmla/server/adapter/soapmessage/XmlaApiAdapter.java

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -210,16 +210,17 @@ public XmlaApiAdapter(XmlaService xmlaService) {
210210
public SOAPMessage handleRequest(SOAPMessage messageRequest, Map<String, Object> headers) {
211211
try {
212212
SOAPMessage messageResponse = MessageFactory.newInstance().createMessage();
213+
messageResponse.setProperty(SOAPMessage.WRITE_XML_DECLARATION, "true");
213214
SOAPPart soapPartResponse = messageResponse.getSOAPPart();
214215
SOAPEnvelope envelopeResponse = soapPartResponse.getEnvelope();
215216

216-
envelopeResponse.addNamespaceDeclaration(Constants.MSXMLA.PREFIX, Constants.MSXMLA.NS_URN);
217-
envelopeResponse.addNamespaceDeclaration(Constants.ROWSET.PREFIX, Constants.ROWSET.NS_URN);
218-
envelopeResponse.addNamespaceDeclaration(Constants.MDDATASET.PREFIX, Constants.MDDATASET.NS_URN);
219-
envelopeResponse.addNamespaceDeclaration(Constants.ENGINE.PREFIX, Constants.ENGINE.NS_URN);
220-
envelopeResponse.addNamespaceDeclaration(Constants.ENGINE200.PREFIX, Constants.ENGINE200.NS_URN);
221-
envelopeResponse.addNamespaceDeclaration(Constants.EMPTY.PREFIX, Constants.EMPTY.NS_URN);
222-
envelopeResponse.addNamespaceDeclaration(Constants.XSI.PREFIX, Constants.XSI.NS_URN);
217+
//envelopeResponse.addNamespaceDeclaration(Constants.MSXMLA.PREFIX, Constants.MSXMLA.NS_URN);
218+
//envelopeResponse.addNamespaceDeclaration(Constants.ROWSET.PREFIX, Constants.ROWSET.NS_URN);
219+
//envelopeResponse.addNamespaceDeclaration(Constants.MDDATASET.PREFIX, Constants.MDDATASET.NS_URN);
220+
//envelopeResponse.addNamespaceDeclaration(Constants.ENGINE.PREFIX, Constants.ENGINE.NS_URN);
221+
//envelopeResponse.addNamespaceDeclaration(Constants.ENGINE200.PREFIX, Constants.ENGINE200.NS_URN);
222+
//envelopeResponse.addNamespaceDeclaration(Constants.EMPTY.PREFIX, Constants.EMPTY.NS_URN);
223+
//envelopeResponse.addNamespaceDeclaration(Constants.XSI.PREFIX, Constants.XSI.NS_URN);
223224

224225
Object role = headers.get("ROLE");
225226
Object user = headers.get("USER");
@@ -229,6 +230,9 @@ public SOAPMessage handleRequest(SOAPMessage messageRequest, Map<String, Object>
229230
SOAPHeader header = envelopeResponse.getHeader();
230231
SOAPHeaderElement sessionElement = header.addHeaderElement(QN_SESSION);
231232
sessionElement.addAttribute(new QName("SessionId"), oSession.get().sessionId());
233+
} else {
234+
SOAPHeader header = envelopeResponse.getHeader();
235+
header.setValue("\n");
232236
}
233237
RequestMetaData metaData = RequestMetaDataUtils.getRequestMetaData(headers, oSession);
234238
SOAPBody bodyResponse = envelopeResponse.getBody();

0 commit comments

Comments
 (0)