由于php.net上的SOAP手册不是很友好,我找不到任何好的例子,我会在这里发布我的问题.
如何创建PHP SOAP请求看起来像这样?
POST /MySERVER/myWSDLservice.asmx HTTP/1.1
Host: connection.mywebsite.com
Content-Type: text/xml; charset=utf-8
Content-Length: length
SOAPAction: "http://connection.mywebsite.com/MySERVER/GetCarType"
<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
<soap:Body>
<GetCarType xmlns="http://connection.mywebsite.com/MySERVER/">
<IDNumber>string</IDNumber>
</GetCarType>
</soap:Body>
</soap:Envelope>
Run Code Online (Sandbox Code Playgroud)
请注意:
任何建议/链接/示例非常感谢.
我的应用程序通常连接到第三方服务器以通过SOAP/WSDL获取数据:
$this->soap_client = new SoapClient("https://[the-domain]:443/[path]?wsdl", array(
'trace'=>1,
'login'=>$this->username,
'password'=>$this->password,
'exceptions' => true,
'cache_wsdl' => WSDL_CACHE_NONE
)
Run Code Online (Sandbox Code Playgroud)
去年一切都很好,但他们最近更新了他们的WSDL文件,现在当应用程序尝试连接时,我收到以下两个错误:
SoapClient::SoapClient(http://[the-domain]:80/[path]?xsd=1): failed to open stream: HTTP request failed! HTTP/1.1 401 Unauthorized
和
SoapClient::SoapClient(): I/O warning : failed to load external entity "http://[the-domain]:80/[path]?xsd=1"
当我查看WSDL XML文件时,看起来违规的可卸载文件是它试图导入的文档模式文件(schemaLocation):( 来自WSDL :)
<types>
<xsd:schema>
<xsd:import namespace="[irrelevant]" schemaLocation="http://[the-domain]:80/[path]?xsd=1"/>
</xsd:schema>
</types>
Run Code Online (Sandbox Code Playgroud)
我已经打了一会儿反对这一点,据我所知,问题是两件事之一:
302 redirects到httpsURL(并删除端口声明)时.尝试导入架构时,SOAP调用是否可能不遵循重定向?假设这是第二个问题,有没有办法可以强制系统使用不同的架构URL而无需下载WSDL文件,编辑它,并在本地存储/引用它?如果是这样,我可以尝试传递URL(http://username:password@domain....)中的凭据?
如果我唯一的目的是创建WSDL和XSD模式文件的修改副本,那么就这样吧,但是我很想知道是否有人有任何想法可以让我避免这种情况(因为模式确实从时间变化 - 到时间).
我有一个带有以下链接的web服务
我正在尝试访问函数名称,SubmitRequestType但似乎函数不存在而不是submitAnsiSingle这是我到目前为止尝试的正确的函数名称,
$wsdl = 'https://ww3.navicure.com:7000/webservices/NavicureSubmissionService?WSDL';
class SecurityHeaderType {
private $submitterIdentifier;
private $originatingIdentifier;
private $submitterPassword;
private $submissionId;
function SecurityHeaderType() {
$this->submitterIdentifier = '***';
$this->originatingIdentifier = '****';
$this->submitterPassword = '****';
$this->submissionId = '';
}
}
class SubmitRequestType {
private $submitterIdentifier;
private $originatingIdentifier;
private $submitterPassword;
private $submissionId;
private $timeout;
private $transactionType;
private $submittedAnsiVersion;
private $resultAnsiVersion;
private $submitterSubmissionId;
private $processingOption;
private $payload;
private $exceptions;
function SubmitRequestType() {
$this->submitterIdentifier = '***';
$this->originatingIdentifier = '***';
$this->submitterPassword = '**';
$this->submissionId = …Run Code Online (Sandbox Code Playgroud)