我正在使用我的私人项目的网站服务。用xml文件创建php请求
我有一个XML文件,像这样的:
<Request Originator="xxxxx" Company="xxx">
<Range Code="xx">
<Item Id="xxxxxx-xxxxx-xxxxxx-xxx-7E8B94462F2C" />
</Range>
<KeyValues>
<Translations>
<Language Value="de" />
<Language Value="en" />
</Translations>
<Regions Show="true" />
<Towns Show="true" />
</KeyValues>
</Request>
编辑 所以对于我知道,直到今天:是一个我将请求发送到这个网址:http://interface.deskline.net/DSI/KeyValue.asmx?WSDL 与该服务器我进行通信,但始终得到此错误消息:
soap:ReceiverSystem.Web.Services.Protocols.SoapException: Server was unable to process request. ---> System.Xml.XmlException: Data at the root level is invalid. Line 1, position 1. at System.Xml.XmlTextReaderImpl.Throw(Exception e) at System.Xml.XmlTextReaderImpl.ParseRootLevelWhitespace() at System.Xml.XmlTextReaderImpl.ParseDocumentContent() at System.Web.Services.Protocols.SoapServerProtocol.SoapEnvelopeReader.Read() at System.Xml.XmlReader.MoveToContent() at System.Web.Services.Protocols.SoapServerProtocolHelper.GetRequestElement() at System.Web.Services.Protocols.Soap12ServerProtocolHelper.RouteRequest() at System.Web.Services.Protocols.SoapServerProtocol.Initialize() at System.Web.Services.Protocols.ServerProtocolFactory.Create(Type type, HttpContext context, HttpRequest request, HttpResponse response, Boolean& abortProcessing) --- End of inner exception stack trace ---1
我不明白它的沟通。这里是一个小的PHP代码,我写的:
$url = 'http://interfacetest.deskline.net/DSI/KeyValue.asmx';
$content = 0;
if (file_exists('/mm/request.xml')) {
$xml = fopen('/mm/request.xml', "r");
$content = fread($xml,filesize("/mm/request.xml"));
fclose($xml);
} else {
echo 'No file, no request';
}
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
// Following line is compulsary to add as it is:
curl_setopt($ch, CURLOPT_POSTFIELDS,
"xmlRequest=" . $content);
$response = curl_exec($ch);
echo $response;