我试图发出SOAP请求,但为此我必须获得授权。如果我试图在未经授权的情况下调用函数,我会收到有关它的错误,一切都好。
但是当我试图这样做时,我总是得到那个错误:Parsing Schema: can't import schema from 'http://www.w3.org/2005/05/xmlmime'
但如果我用SoapUI做到这一点,一切正常。
我发现我必须发送登录名和密码作为对象参数,这是我的代码示例,但它回复给我关于Parsing Schema: can't....
$wsdl = 'source/my.wsdl';
$client = new SoapClient($wsdl,
array(
'trace' => 1,
'exception' => 0,
'login' => 'test',
'password' => 'test123'
));
我没有找到任何其他方法,只能使用NuSOAP,比如setCredentials(),但这也不行。
现在我尝试用NuSOAP做到这一点:
ini_set('display_errors', '1');
ini_set('error_reporting', E_ALL &~ (E_NOTICE | E_STRICT));
//ini_set('error_reporting', E_ALL);
require_once 'lib/nusoap.php';
$params = array(
'ID' => '',
'Portal' => 'test1',
'CK' => 'test2'
);
$wsdl = 'source/test.wsdl';
$client = new nusoap_client($wsdl, true);
$client->setCredentials('test_login', 'test_password', 'basic');
$result = $client->call('testFunction', $params);
if ($client->fault) {
echo "<h2>Fault</h2><pre>";
print_r($result);
echo "</pre>";
} else {
$error = $client->getError();
if ($error) {
echo "<h2>Error</h2><pre>" . $error . "</pre>";
} else {
echo "<h2>Main</h2>";
echo $result;
}
}
echo "<h2>Request</h2>";
echo "<pre>" . htmlspecialchars($client->request, ENT_QUOTES) . "</pre>";
echo "<h2>Response</h2>";
echo "<pre>" . htmlspecialchars($client->response, ENT_QUOTES) . "</pre>";
print_r($client->response);
并得到同样的问题wsdl error: Getting http://www.w3.org/2005/05/xmlmime - HTTP ERROR: Unsupported HTTP response status 307 Temporary Redirect (soapclient->response has contents of the response)
如果我删除字符串$client->setCredentials('test_login', 'test_password', 'basic');
我会收到有关Not Authorized
的错误消息。
http://www.w3.org/2005/05/xmlmime
的问题是什么?这是我试图调用测试功能的第三天,但总是得到错误。我不知道还能做些什么。
从NuSOAP所有工作正常,基本认证,所有请求,响应,都很好。
WSDL内容:
<definitions targetNamespace="http://**.**.com/SM/7" xsi:schemaLocation="http://schemas.xmlsoap.org/wsdl/ http://schemas.xmlsoap.org/wsdl/" xmlns="http://schemas.xmlsoap.org/wsdl/" xmlns:cmn="http://**.**.com/SM/7/Common" xmlns:http="http://schemas.xmlsoap.org/wsdl/http/" xmlns:mime="http://schemas.xmlsoap.org/wsdl/mime/" xmlns:ns="http://**.**.com/SM/7" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<types>
<xs:schema attributeFormDefault="unqualified" elementFormDefault="qualified" targetNamespace="http://**.**.com/SM/7" version="2014-10-02 Rev 1" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns="http://**.**.com/SM/7" xmlns:xmime="http://www.w3.org/2005/05/xmlmime">
<xs:import namespace="http://www.w3.org/2005/05/xmlmime" schemaLocation="http://www.w3.org/2005/05/xmlmime"/>
<xs:import namespace="http://**.**.com/SM/7/Common" schemaLocation="http://***.**.**.**:8090/1/SM/7/Common.xsd"/>
<xs:complexType name="HPSMInteractionsFromMosRuKeysType">
<xs:sequence>
<xs:element minOccurs="0" name="ID" nillable="true" type="cmn:StringType"/>
</xs:sequence>
<xs:attribute name="query" type="xs:string" use="optional"/>
<xs:attribute name="updatecounter" type="xs:long" use="optional"/>
</xs:complexType>
<xs:complexType name="HPSMInteractionsFromMosRuInstanceType">
<xs:sequence>
<xs:element minOccurs="0" name="ID" nillable="true" type="cmn:StringType"/>
<xs:element minOccurs="0" name="Description">
<xs:complexType>
<xs:complexContent>
<xs:extension base="cmn:ArrayType">
<xs:sequence>
<xs:element maxOccurs="unbounded" minOccurs="0" name="Description" type="cmn:StringType"/>
</xs:sequence>
</xs:extension>
</xs:complexContent>
</xs:complexType>
</xs:element>
<xs:element minOccurs="0" name="Resolution">
<xs:complexType>
<xs:complexContent>
<xs:extension base="cmn:ArrayType">
<xs:sequence>
<xs:element maxOccurs="unbounded" minOccurs="0" name="Resolution" type="cmn:StringType"/>
</xs:sequence>
</xs:extension>
</xs:complexContent>
</xs:complexType>
</xs:element>
<xs:element minOccurs="0" name="ResolutionCode" nillable="true" type="cmn:StringType"/>
<xs:element minOccurs="0" name="Email" nillable="true" type="cmn:StringType"/>
<xs:element minOccurs="0" name="User" nillable="true" type="cmn:StringType"/>
<xs:element minOccurs="0" name="Title" nillable="true" type="cmn:StringType"/>
<xs:element minOccurs="0" name="Status" nillable="true" type="cmn:StringType"/>
<xs:element minOccurs="0" name="Rating" nillable="true" type="cmn:StringType"/>
<xs:element minOccurs="0" name="ProblemType" nillable="true" type="cmn:StringType"/>
<xs:element minOccurs="0" name="Deadline" nillable="true" type="cmn:DateTimeType"/>
<xs:element minOccurs="0" name="Feedback">
<xs:complexType>
<xs:complexContent>
<xs:extension base="cmn:ArrayType">
<xs:sequence>
<xs:element maxOccurs="unbounded" minOccurs="0" name="Feedback" type="cmn:StringType"/>
</xs:sequence>
</xs:extension>
</xs:complexContent>
</xs:complexType>
</xs:element>
<xs:element minOccurs="0" name="UserID" nillable="true" type="cmn:StringType"/>
<xs:element minOccurs="0" name="Portal" nillable="true" type="cmn:StringType"/>
<xs:element minOccurs="0" name="SSOID" nillable="true" type="cmn:StringType"/>
<xs:element minOccurs="0" name="CK" nillable="true" type="cmn:StringType"/>
<xs:element minOccurs="0" name="Comments">
<xs:complexType>
<xs:complexContent>
<xs:extension base="cmn:ArrayType">
<xs:sequence>
<xs:element maxOccurs="unbounded" minOccurs="0" name="Comments" type="cmn:StringType"/>
</xs:sequence>
</xs:extension>
</xs:complexContent>
</xs:complexType>
</xs:element>
<xs:element minOccurs="0" name="attachments" nillable="true" type="cmn:AttachmentsType"/>
</xs:sequence>
<xs:attribute name="query" type="xs:string" use="optional"/>
<xs:attribute name="uniquequery" type="xs:string" use="optional"/>
<xs:attribute name="recordid" type="xs:string" use="optional"/>
<xs:attribute name="updatecounter" type="xs:long" use="optional"/>
</xs:complexType>
<xs:complexType name="HPSMInteractionsFromMosRuModelType">
<xs:sequence>
<xs:element name="keys" type="HPSMInteractionsFromMosRuKeysType"/>
<xs:element name="instance" type="HPSMInteractionsFromMosRuInstanceType"/>
<xs:element minOccurs="0" name="messages" type="cmn:MessagesType"/>
</xs:sequence>
<xs:attribute name="query" type="xs:string" use="optional"/>
</xs:complexType>
<xs:element name="RetrieveHPSMInteractionsFromMosRuRequest">
<xs:complexType>
<xs:sequence>
<xs:element name="model" type="HPSMInteractionsFromMosRuModelType"/>
</xs:sequence>
<xs:attribute name="attachmentInfo" type="xs:boolean" use="optional"/>
<xs:attribute name="attachmentData" type="xs:boolean" use="optional"/>
<xs:attribute default="true" name="ignoreEmptyElements" type="xs:boolean" use="optional"/>
<xs:attribute name="updatecounter" type="xs:boolean" use="optional"/>
<xs:attribute name="handle" type="xs:string" use="optional"/>
<xs:attribute name="count" type="xs:long" use="optional"/>
<xs:attribute name="start" type="xs:long" use="optional"/>
</xs:complexType>
</xs:element>
<xs:element name="RetrieveHPSMInteractionsFromMosRuResponse">
<xs:complexType>
<xs:sequence>
<xs:element name="model" type="HPSMInteractionsFromMosRuModelType"/>
<xs:element minOccurs="0" name="messages" type="cmn:MessagesType"/>
</xs:sequence>
<xs:attribute name="status" type="cmn:StatusType" use="required"/>
<xs:attribute name="message" type="xs:string" use="required"/>
<xs:attribute name="schemaRevisionDate" type="xs:date" use="required"/>
<xs:attribute name="schemaRevisionLevel" type="xs:int" use="required"/>
<xs:attribute name="returnCode" type="xs:decimal" use="optional"/>
<xs:attribute name="query" type="xs:string" use="optional"/>
<xs:attribute name="handle" type="xs:string" use="optional"/>
<xs:attribute name="count" type="xs:long" use="optional"/>
<xs:attribute name="more" type="xs:boolean" use="optional"/>
<xs:attribute name="start" type="xs:long" use="optional"/>
</xs:complexType>
</xs:element>
<xs:element name="RetrieveHPSMInteractionsFromMosRuKeysListRequest">
<xs:complexType>
<xs:sequence>
<xs:element name="model" type="HPSMInteractionsFromMosRuModelType"/>
</xs:sequence>
<xs:attribute name="attachmentInfo" type="xs:boolean" use="optional"/>
<xs:attribute name="attachmentData" type="xs:boolean" use="optional"/>
<xs:attribute default="true" name="ignoreEmptyElements" type="xs:boolean" use="optional"/>
<xs:attribute name="updatecounter" type="xs:boolean" use="optional"/>
<xs:attribute name="handle" type="xs:string" use="optional"/>
<xs:attribute name="count" type="xs:long" use="optional"/>
<xs:attribute name="start" type="xs:long" use="optional"/>
</xs:complexType>
</xs:element>
<xs:element name="RetrieveHPSMInteractionsFromMosRuKeysListResponse">
<xs:complexType>
<xs:sequence>
<xs:element maxOccurs="unbounded" name="keys" type="HPSMInteractionsFromMosRuKeysType"/>
<xs:element minOccurs="0" name="messages" type="cmn:MessagesType"/>
</xs:sequence>
<xs:attribute name="status" type="cmn:StatusType" use="required"/>
<xs:attribute name="message" type="xs:string" use="required"/>
<xs:attribute name="schemaRevisionDate" type="xs:date" use="required"/>
<xs:attribute name="schemaRevisionLevel" type="xs:int" use="required"/>
<xs:attribute name="returnCode" type="xs:decimal" use="optional"/>
<xs:attribute name="query" type="xs:string" use="optional"/>
<xs:attribute name="handle" type="xs:string" use="optional"/>
<xs:attribute name="count" type="xs:long" use="optional"/>
<xs:attribute name="more" type="xs:boolean" use="optional"/>
<xs:attribute name="start" type="xs:long" use="optional"/>
</xs:complexType>
</xs:element>
<xs:element name="RetrieveHPSMInteractionsFromMosRuListRequest">
<xs:complexType>
<xs:sequence>
<xs:element maxOccurs="unbounded" name="keys" type="HPSMInteractionsFromMosRuKeysType"/>
</xs:sequence>
<xs:attribute name="attachmentInfo" type="xs:boolean" use="optional"/>
<xs:attribute name="attachmentData" type="xs:boolean" use="optional"/>
<xs:attribute default="true" name="ignoreEmptyElements" type="xs:boolean" use="optional"/>
<xs:attribute name="updatecounter" type="xs:boolean" use="optional"/>
<xs:attribute name="handle" type="xs:string" use="optional"/>
<xs:attribute name="count" type="xs:long" use="optional"/>
<xs:attribute name="start" type="xs:long" use="optional"/>
<xs:attribute name="attachmentType" type="xs:long" use="optional"/>
</xs:complexType>
</xs:element>
<xs:element name="RetrieveHPSMInteractionsFromMosRuListResponse">
<xs:complexType>
<xs:sequence>
<xs:element maxOccurs="unbounded" name="instance" type="HPSMInteractionsFromMosRuInstanceType"/>
<xs:element minOccurs="0" name="messages" type="cmn:MessagesType"/>
</xs:sequence>
<xs:attribute name="status" type="cmn:StatusType" use="required"/>
<xs:attribute name="message" type="xs:string" use="required"/>
<xs:attribute name="schemaRevisionDate" type="xs:date" use="required"/>
<xs:attribute name="schemaRevisionLevel" type="xs:int" use="required"/>
<xs:attribute name="returnCode" type="xs:decimal" use="optional"/>
<xs:attribute name="query" type="xs:string" use="optional"/>
<xs:attribute name="handle" type="xs:string" use="optional"/>
<xs:attribute name="count" type="xs:long" use="optional"/>
<xs:attribute name="more" type="xs:boolean" use="optional"/>
<xs:attribute name="start" type="xs:long" use="optional"/>
</xs:complexType>
</xs:element>
<xs:element name="CreateHPSMInteractionsFromMosRuRequest">
<xs:complexType>
<xs:sequence>
<xs:element name="model" type="HPSMInteractionsFromMosRuModelType"/>
</xs:sequence>
<xs:attribute name="attachmentInfo" type="xs:boolean" use="optional"/>
<xs:attribute name="attachmentData" type="xs:boolean" use="optional"/>
<xs:attribute default="true" name="ignoreEmptyElements" type="xs:boolean" use="optional"/>
<xs:attribute name="updateconstraint" type="xs:long" use="optional"/>
</xs:complexType>
</xs:element>
<xs:element name="CreateHPSMInteractionsFromMosRuResponse">
<xs:complexType>
<xs:sequence>
<xs:element name="model" type="HPSMInteractionsFromMosRuModelType"/>
<xs:element minOccurs="0" name="messages" type="cmn:MessagesType"/>
</xs:sequence>
<xs:attribute name="status" type="cmn:StatusType" use="required"/>
<xs:attribute name="message" type="xs:string" use="required"/>
<xs:attribute name="schemaRevisionDate" type="xs:date" use="required"/>
<xs:attribute name="schemaRevisionLevel" type="xs:int" use="required"/>
<xs:attribute name="returnCode" type="xs:decimal" use="optional"/>
<xs:attribute name="query" type="xs:string" use="optional"/>
</xs:complexType>
</xs:element>
<xs:element name="UpdateHPSMInteractionsFromMosRuRequest">
<xs:complexType>
<xs:sequence>
<xs:element name="model" type="HPSMInteractionsFromMosRuModelType"/>
</xs:sequence>
<xs:attribute name="attachmentInfo" type="xs:boolean" use="optional"/>
<xs:attribute name="attachmentData" type="xs:boolean" use="optional"/>
<xs:attribute default="true" name="ignoreEmptyElements" type="xs:boolean" use="optional"/>
<xs:attribute name="updateconstraint" type="xs:long" use="optional"/>
</xs:complexType>
</xs:element>
<xs:element name="UpdateHPSMInteractionsFromMosRuResponse">
<xs:complexType>
<xs:sequence>
<xs:element name="model" type="HPSMInteractionsFromMosRuModelType"/>
<xs:element minOccurs="0" name="messages" type="cmn:MessagesType"/>
</xs:sequence>
<xs:attribute name="status" type="cmn:StatusType" use="required"/>
<xs:attribute name="message" type="xs:string" use="required"/>
<xs:attribute name="schemaRevisionDate" type="xs:date" use="required"/>
<xs:attribute name="schemaRevisionLevel" type="xs:int" use="required"/>
<xs:attribute name="returnCode" type="xs:decimal" use="optional"/>
<xs:attribute name="query" type="xs:string" use="optional"/>
</xs:complexType>
</xs:element>
</xs:schema>
</types>
<message name="RetrieveHPSMInteractionsFromMosRuRequest">
<part element="ns:RetrieveHPSMInteractionsFromMosRuRequest" name="RetrieveHPSMInteractionsFromMosRuRequest"/>
</message>
<message name="RetrieveHPSMInteractionsFromMosRuResponse">
<part element="ns:RetrieveHPSMInteractionsFromMosRuResponse" name="RetrieveHPSMInteractionsFromMosRuResponse"/>
</message>
<message name="RetrieveHPSMInteractionsFromMosRuKeysListRequest">
<part element="ns:RetrieveHPSMInteractionsFromMosRuKeysListRequest" name="RetrieveHPSMInteractionsFromMosRuKeysListRequest"/>
</message>
<message name="RetrieveHPSMInteractionsFromMosRuKeysListResponse">
<part element="ns:RetrieveHPSMInteractionsFromMosRuKeysListResponse" name="RetrieveHPSMInteractionsFromMosRuKeysListResponse"/>
</message>
<message name="RetrieveHPSMInteractionsFromMosRuListRequest">
<part element="ns:RetrieveHPSMInteractionsFromMosRuListRequest" name="RetrieveHPSMInteractionsFromMosRuListRequest"/>
</message>
<message name="RetrieveHPSMInteractionsFromMosRuListResponse">
<part element="ns:RetrieveHPSMInteractionsFromMosRuListResponse" name="RetrieveHPSMInteractionsFromMosRuListResponse"/>
</message>
<message name="CreateHPSMInteractionsFromMosRuRequest">
<part element="ns:CreateHPSMInteractionsFromMosRuRequest" name="CreateHPSMInteractionsFromMosRuRequest"/>
</message>
<message name="CreateHPSMInteractionsFromMosRuResponse">
<part element="ns:CreateHPSMInteractionsFromMosRuResponse" name="CreateHPSMInteractionsFromMosRuResponse"/>
</message>
<message name="UpdateHPSMInteractionsFromMosRuRequest">
<part element="ns:UpdateHPSMInteractionsFromMosRuRequest" name="UpdateHPSMInteractionsFromMosRuRequest"/>
</message>
<message name="UpdateHPSMInteractionsFromMosRuResponse">
<part element="ns:UpdateHPSMInteractionsFromMosRuResponse" name="UpdateHPSMInteractionsFromMosRuResponse"/>
</message>
<portType name="HPSMInteractionsFromMosRu">
<operation name="RetrieveHPSMInteractionsFromMosRu">
<documentation/>
<input message="ns:RetrieveHPSMInteractionsFromMosRuRequest"/>
<output message="ns:RetrieveHPSMInteractionsFromMosRuResponse"/>
</operation>
<operation name="RetrieveHPSMInteractionsFromMosRuKeysList">
<documentation/>
<input message="ns:RetrieveHPSMInteractionsFromMosRuKeysListRequest"/>
<output message="ns:RetrieveHPSMInteractionsFromMosRuKeysListResponse"/>
</operation>
<operation name="RetrieveHPSMInteractionsFromMosRuList">
<documentation/>
<input message="ns:RetrieveHPSMInteractionsFromMosRuListRequest"/>
<output message="ns:RetrieveHPSMInteractionsFromMosRuListResponse"/>
</operation>
<operation name="CreateHPSMInteractionsFromMosRu">
<documentation/>
<input message="ns:CreateHPSMInteractionsFromMosRuRequest"/>
<output message="ns:CreateHPSMInteractionsFromMosRuResponse"/>
</operation>
<operation name="UpdateHPSMInteractionsFromMosRu">
<documentation/>
<input message="ns:UpdateHPSMInteractionsFromMosRuRequest"/>
<output message="ns:UpdateHPSMInteractionsFromMosRuResponse"/>
</operation>
</portType>
<binding name="HPSMInteractionsFromMosRu" type="ns:HPSMInteractionsFromMosRu">
<soap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"/>
<operation name="RetrieveHPSMInteractionsFromMosRu">
<soap:operation soapAction="Retrieve" style="document"/>
<input>
<soap:body use="literal"/>
</input>
<output>
<soap:body use="literal"/>
</output>
</operation>
<operation name="RetrieveHPSMInteractionsFromMosRuKeysList">
<soap:operation soapAction="RetrieveKeysList" style="document"/>
<input>
<soap:body use="literal"/>
</input>
<output>
<soap:body use="literal"/>
</output>
</operation>
<operation name="RetrieveHPSMInteractionsFromMosRuList">
<soap:operation soapAction="RetrieveList" style="document"/>
<input>
<soap:body use="literal"/>
</input>
<output>
<soap:body use="literal"/>
</output>
</operation>
<operation name="CreateHPSMInteractionsFromMosRu">
<soap:operation soapAction="Create" style="document"/>
<input>
<soap:body use="literal"/>
</input>
<output>
<soap:body use="literal"/>
</output>
</operation>
<operation name="UpdateHPSMInteractionsFromMosRu">
<soap:operation soapAction="Update" style="document"/>
<input>
<soap:body use="literal"/>
</input>
<output>
<soap:body use="literal"/>
</output>
</operation>
</binding>
<service name="HPSMInteractionsFromMosRu">
<port binding="ns:HPSMInteractionsFromMosRu" name="HPSMInteractionsFromMosRu">
<soap:address location="http://***.**.**.**:8090/1/SM/7/ws"/>
</port>
</service>
</definitions>
答案 0 :(得分:0)
我为我找到了解决方案!
该错误的问题在于我无法从我的脚本中获取该文件,因此您需要在本地保存它们:
我将该文件(http://www.w3.org/2005/05/xmlmime
)保存到我的工作目录中,并将WSDL文件路径(schemaLocation=...
)也更改为我的本地副本
现在它看起来像这样(在WSDL中(
<xs:import namespace="http://www.w3.org/2005/05/xmlmime" schemaLocation="http://mydomain/xmlmime.xml"/>
<xs:import namespace="http://schemas.hp.com/SM/7/Common" schemaLocation="http://mydomain/Common.xsd"/>
并在Common.xsd
<xs:import namespace="http://www.w3.org/2005/05/xmlmime" schemaLocation="http://mydomain/xmlmime.xml"/>
现在我没有收到这个错误!
P.S在我的情况下,我从服务器端开发人员收到的WSDL文件中存在其他一些错误的文件路径,但它特别适用于我的情况。所以总是checke URI路径。 :)