我正在为我遇到的问题寻求帮助。我试图通过使用php SOAP将文件提交到服务器但是当我提交时,我有这个错误:
Fatal error: Uncaught SoapFault exception: [soap11env:Client.SchemaValidationError] :2:0:ERROR:SCHEMASV:SCHEMAV_ELEMENT_CONTENT: Element '{http://mutalyzer.nl/2.0/services}submitBatchJob': Missing child element(s). Expected is ( {http://mutalyzer.nl/2.0/services}data ). in C:\xampp\htdocs\ngs\submit4.php:31 Stack trace: #0 C:\xampp\htdocs\ngs\submit4.php(31): SoapClient->__call('submitBatchJob', Array) #1 {main} thrown in C:\xampp\htdocs\ngs\submit4.php on line 31
WSDL描述如下:
submitBatchJob类型submitBatchJob
data type base64Binary
process - optional, nillable; type string
argument - optional, nillable; type string
email - optional, nillable; type string
submitBatchJobResponse类型submitBatchJobResponse
submitBatchJobResult - optional, nillable; type string
<xs:complexType name="submitBatchJob">
<xs:sequence>
<xs:element name="data" type="xs:base64Binary" />
<xs:element name="process" type="xs:string" minOccurs="0" nillable="true" />
<xs:element name="argument" type="xs:string" minOccurs="0" nillable="true" />
<xs:element name="email" type="xs:string" minOccurs="0" nillable="true" />
</xs:sequence>
</xs:complexType>
这是我的php脚本:
<?php
$URL = 'https://mutalyzer.nl/services/?wsdl';
?><!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Mutalyzer SOAP client</title>
</head>
<body>
<h1>Mutalyzer SOAP client</h1>
<?php
if (isset($_GET['data']) && $_GET['data']) {
$variant = $_GET['data'];
$_FILES['data']['name']=$_GET['data'];
$filename = basename( $_FILES['data']['name']);
$file = fopen($filename, "r");
$handle = fread($file,filesize($filename));
$data = base64_encode($handle);
$NameChecker=$_GET['process'];
echo '<h2>Result for '.htmlentities($variant).'</h2>';
$options = array('features' => SOAP_SINGLE_ELEMENT_ARRAYS);
$client = new SoapClient($URL);
$result = $client->submitBatchJob($data, $NameChecker)
->submitBatchJobResult;
print_r($result);
}
?>
<h2>Submit job data file to MUTALYZER</h2>
<form action="" method="GET" enctype="multipart/form-data">
<p>
Input file:
</p>
<input name="data" type="file" id="data" />
<br/>
Process :
<input type="text" size="10" name="process" id="process" value="NameChecker"/>
<br/>
<input type="submit" name="upload" value="Submit" />
</form>
</body>
</html>
有谁知道我做错了什么以及如何纠正我的脚本? 非常感谢。
答案 0 :(得分:0)
首先,您需要捕获该异常,并使用:
try {
# some code here that causes a problem, hint: soap11env:Client.SchemaValidationError
} catch (Exception $e) {
echo $e->getMessage();
}
其次,它告诉你错误在哪里:
Element '{http://mutalyzer.nl/2.0/services}submitBatchJob': Missing child element(s). Expected is ( {http://mutalyzer.nl/2.0/services}data ).
还有:
in C:\xampp\htdocs\ngs\submit4.php:31 Stack trace: #0 C:\xampp\htdocs\ngs\submit4.php(31): SoapClient->__call('submitBatchJob', Array) #1 {main} thrown in C:\xampp\htdocs\ngs\submit4.php on line 31