我正在尝试从本地机器读取 XML 文件。但是,以下代码:
$datasourceXmlFilePath=$configuration.config.mondrian.DataSources.filePath
$webXmlFilePath=$configuration.config.mondrian.web.'web-app'.filePath
if(!(Test-Path($datasourceXmlFilePath)))
{
Write-Host "Datasource.xml not found. Exiting the script" -ForegroundColor red
exit
}
if(!(Test-Path($webXmlFilePath)))
{
Write-Host "Web.xml not found. Exiting the script" -ForegroundColor red
exit
}
[xml]$datasourceXml=Get-Content $datasourceXmlFilePath
Write-Host "XML created"
[xml]$webl= Get-content $webXmlFilePath
Write-Host "XML Created"
不断给我以下错误:
XML created
Cannot convert value "System.Object[]" to type "System.Xml.XmlDocument". Error: "The remote server returned an error: (407) Pr
oxy Authentication Required."
At line:20 char:11
+ [xml]$webl <<<< = Get-content $webXmlFilePath
+ CategoryInfo : MetadataError: (:) [], ParentContainsErrorRecordException
+ FullyQualifiedErrorId : RuntimeException
这两个 XML 格式都很好,我很困惑为什么一个文件被成功读取而另一个文件没有。我尝试更改第二个 xml 文件的位置,但仍然得到相同的结果。
我正在使用 WindowsPowershell_ise v1.0,在 Windows 7 机器上运行。
出现问题的 xml 文件是:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE web-app
PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
"http://java.sun.com/dtd/web-app_2_3.dtd">
<web-app>
<display-name>Mondrian</display-name>
<description/>
<!-- optional? now in JPivot by default -->
<context-param>
<param-name>contextFactory</param-name>
<param-value>com.tonbeller.wcf.controller.RequestContextFactoryImpl</param-value>
</context-param>
<context-param>
<param-name>connectString</param-name>
<!--<param-value>Provider=Mondrian;Jdbc=jdbc:mysql://localhost:3306/foodmart?user=root&password=;Catalog=/WEB-INF/queries/FoodMart.xml;JdbcDrivers=com.mysql.jdbc.Driver</param-value>-->
<param-value>Provider=Mondrian;Jdbc='jdbc:sqlserver://172.25.37.213;user=QwikSilver_user;password=Newuser123;databaseName=FoodMart;';Catalog=/WEB-INF/queries/FoodMart.xml;JdbcDrivers=com.microsoft.sqlserver.jdbc.SQLServerDriver</param-value>
</context-param>
<!-- optional
<context-param>
<param-name>chartServlet</param-name>
<param-value>/path/to/chartServlet</param-value>
</context-param>
-->
<filter>
<filter-name>JPivotController</filter-name>
<filter-class>com.tonbeller.wcf.controller.RequestFilter</filter-class>
<init-param>
<param-name>errorJSP</param-name>
<param-value>/error.jsp</param-value>
<description>URI of error page</description>
</init-param>
<init-param>
<param-name>busyJSP</param-name>
<param-value>/busy.jsp</param-value>
<description>This page is displayed if a the user clicks
on a query before the previous query has finished</description>
</init-param>
<!--
<init-param>
<param-name>forceExtension</param-name>
<param-value>.faces</param-value>
<description>replace .jsp with .faces</description>
</init-param>
-->
</filter>
<filter-mapping>
<filter-name>JPivotController</filter-name>
<url-pattern>/testpage.jsp</url-pattern>
</filter-mapping>
<listener>
<listener-class>mondrian.web.taglib.Listener</listener-class>
</listener>
<!-- resources initializer -->
<listener>
<listener-class>com.tonbeller.tbutils.res.ResourcesFactoryContextListener</listener-class>
</listener>
<servlet>
<servlet-name>MDXQueryServlet</servlet-name>
<servlet-class>mondrian.web.servlet.MdxQueryServlet</servlet-class>
<init-param>
<param-name>connectString</param-name>
<!--<param-value>Provider=Mondrian;Jdbc=jdbc:mysql://localhost:3306/foodmart?user=root&password=;Catalog=/WEB-INF/queries/FoodMart.xml;JdbcDrivers=com.mysql.jdbc.Driver</param-value>-->
<param-value>Provider=Mondrian;Jdbc='jdbc:sqlserver://172.25.37.213;user=QwikSilver_user;password=Newuser123;databaseName=FoodMart;';Catalog=/WEB-INF/queries/FoodMart.xml;JdbcDrivers=com.microsoft.sqlserver.jdbc.SQLServerDriver</param-value>
</init-param>
</servlet>
<servlet>
<servlet-name>MondrianXmlaServlet</servlet-name>
<servlet-class>mondrian.xmla.impl.DynamicDatasourceXmlaServlet</servlet-class>
<!--<servlet-class>mondrian.xmla.impl.DefaultXmlaServlet</servlet-class>-->
<init-param>
<param-name>DataSourcesConfig</param-name>
<param-value>file:D:\setups\apache-tomcat-6.0.24\webapps\mondrian\WEB-INF\datasources.xml</param-value>
</init-param>
<!--
This is an example of how to add a callback to the XML/A servlet.
It must implement mondrian.xmla.XmlaRequestCallback.
<init-param>
<param-name>Callbacks</param-name>
<param-value>com.example.MyCallbackClass;com.example.SomeOtherCallback</param-value>
</init-param>
-->
</servlet>
<!-- jfreechart provided servlet -->
<servlet>
<servlet-name>DisplayChart</servlet-name>
<servlet-class>org.jfree.chart.servlet.DisplayChart</servlet-class>
</servlet>
<!-- jfreechart provided servlet -->
<servlet>
<servlet-name>GetChart</servlet-name>
<display-name>GetChart</display-name>
<description>Default configuration created for servlet.</description>
<servlet-class>com.tonbeller.jpivot.chart.GetChart</servlet-class>
</servlet>
<servlet>
<servlet-name>Print</servlet-name>
<display-name>Print</display-name>
<description>Default configuration created for servlet.</description>
<servlet-class>com.tonbeller.jpivot.print.PrintServlet</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>DisplayChart</servlet-name>
<url-pattern>/DisplayChart</url-pattern>
</servlet-mapping>
<servlet-mapping>
<servlet-name>Print</servlet-name>
<url-pattern>/Print</url-pattern>
</servlet-mapping>
<servlet-mapping>
<servlet-name>GetChart</servlet-name>
<url-pattern>/GetChart</url-pattern>
</servlet-mapping>
<servlet-mapping>
<servlet-name>MDXQueryServlet</servlet-name>
<url-pattern>/mdxquery</url-pattern>
</servlet-mapping>
<servlet-mapping>
<servlet-name>MondrianXmlaServlet</servlet-name>
<url-pattern>/xmla</url-pattern>
</servlet-mapping>
<welcome-file-list>
<welcome-file>index.html</welcome-file>
</welcome-file-list>
<taglib>
<taglib-uri>http://www.tonbeller.com/wcf</taglib-uri>
<taglib-location>/WEB-INF/wcf/wcf-tags.tld</taglib-location>
</taglib>
<taglib>
<taglib-uri>http://www.tonbeller.com/jpivot</taglib-uri>
<taglib-location>/WEB-INF/jpivot/jpivot-tags.tld</taglib-location>
</taglib>
</web-app>
任何帮助,将不胜感激。