我不确定该怎么做。我正在编写的 SOAP 服务的规范表明它需要在响应请求的请求响应之前发回确认消息。
这在 PHP 中是如何完成的?我没有看到如何执行此操作的示例。
来自需求文档:
One acknowledgement message is sent by Integration Partner to Vendor for every SubmitInv message request. A single acknowledgement message is also sent by Vendor to the Integration Partner from every RequestInv message respons
这不是标准的 TCP 确认响应。这是一个自定义 SOAP 格式的响应,表示他们已收到请求。 请参见下面的示例。
询问供应商后:
They claim that it is a legacy system and it was written to process in that flow. They cannot, at this time, change it. I told him that in 20+ yrs programming, I have NEVER seen any SOAP system require an ACK. He claimed that it had to do with having to "wait" for the responses. Apparently they don't understand how to properly handle stateless processing.
我已经尝试使用 FoxVSky 下面概述的 PHP 输出缓冲函数来完成它,它在 SOAP 事务中不起作用。 此外,PHP 内置的标准 SOAP 库和 Zend SOAP 库都没有执行此操作的功能。
示例:
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<soap:Body>
<PAddRs>
<RqUID>f11958c8-3fde-42ca-bd94-94fdfca316ef</RqUID>
<PKey>46dba062-2105-4851-831f-a1d364741329</PKey>
<AppStatus>
<AppStatusCode>Accept</AppStatusCode>
</AppStatus>
</PAddRs>
</soap:Body>
</soap:Envelope>
最佳答案
好的,我已经在我的 SOAP 服务中实现了确认消息传递,这是从客户端调用它的方式:
<?php
require_once __DIR__ . '/vendor/autoload.php';
$options = array();
$options['cache_wsdl'] = WSDL_CACHE_NONE;
$options['soap_version'] = SOAP_1_2;
$client = new Zend\Soap\Client("http://localhost/soap/server.php?wsdl", $options);
try {
// Currently loading example request
$xml = simplexml_load_file('RequestExample.xml');
$t_xml = new DOMDocument();
$t_xml->loadXML($xml->asXML());
$xml = $t_xml->saveXML($t_xml->documentElement);
$response = $client->ReqInv($xml);
} catch (Exception $e) {
$response = 'Exception: '. $e. "\n";
}
echo $response;
还有我的服务:
<?php
require_once __DIR__ . '/vendor/autoload.php';
require(__DIR__ . '/PTResp.php');
use Zend\Soap\AutoDiscover;
use Zend\Soap\Server;
use Zend\Soap\Wsdl;
class PT {
/**
* function ReqInv
* Function to return the inventory for the passed request.
*
* @param string $request
* @return string
*/
function ReqInv($request) {
$pt = new PTResp($request);
return $pt->toString();
}
}
if (isset($_GET['wsdl'])) {
$wsdl = new AutoDiscover();
$wsdl->setUri('http://localhost/soap/server.php');
$wsdl->setClass('PT');
$wsdl->handle();
} else {
$server = new Zend\Soap\Server('http://localhost/soap/server.php?wsdl');
$server->setClass('PT');
$server->setEncoding('ISO-8859-1');
$server->handle();
}
还有我的类(class)(在 PTResp.php 中):
class PT {
function __construct($xml) {
$this->m = new Mustache_Engine;
$this->xml = @simplexml_load_string($xml);
$this->xml->registerXPathNamespace(<my namespace info>);
$this->SendAck();
$this->BuildResponse();
} // function __construct
/*
* This is the function that is actually called to return the response to the client.
*/
function toString() {
$domxml = new DOMDocument('1.0');
$domxml->preserveWhiteSpace = false;
$domxml->formatOutput = true;
$domxml->loadXML($this->response);
$this->response = $domxml->saveXML($domxml->documentElement);
return $this->response;
} // function toString
function SendAck() {
$this->Status = "Accept";
$xml_post_string = $this->m->render(
'<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<soap:Body>
<ProcurementAddRs xmlns=MyNamespaceInfo">
<RqUID>{{RqUID}}</RqUID>
<PKey>{{PKey}}</PKey>
<ApplicationStatus>
<ApplicationStatusCode>{{Status}}</ApplicationStatusCode>
</ApplicationStatus>
</ProcurementAddRs>
</soap:Body>
</soap:Envelope>', array("RqUID" =>$this->RqUID, "PKey"=>$this->PKey, "Status"=>$this->Status));
$url = 'http://localhost/soap/gotit.php'; // in this test, it writes the response to a file. I will be sending it to the endpoint from here
$this->curl_post_async($url, $xml_post_string);
} // function SendAck
function curl_post_async($url, $post_string){
$parts=parse_url($url);
$fp = fsockopen($parts['host'],
isset($parts['port'])?$parts['port']:80,
$errno, $errstr, 30);
$out = "POST ".$parts['path']." HTTP/1.1\r\n";
$out.= "Host: ".$parts['host']."\r\n";
$out.= "Content-Type: text/xml\r\n";
$out.= "Content-Length: ".strlen($post_string)."\r\n";
$out.= "Connection: Close\r\n\r\n";
if (isset($post_string)) $out.= $post_string;
fwrite($fp, $out);
fclose($fp);
} // function curl_post_async
function BuildResponse() {
$this-response = "<XML response that is built goes here>";
}
}
关于php - 异步 PHP SOAP 服务器在响应之前发送确认消息?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50255371/
我正在尝试使用ruby和Savon来使用网络服务。测试服务为http://www.webservicex.net/WS/WSDetails.aspx?WSID=9&CATID=2require'rubygems'require'savon'client=Savon::Client.new"http://www.webservicex.net/stockquote.asmx?WSDL"client.get_quotedo|soap|soap.body={:symbol=>"AAPL"}end返回SOAP异常。检查soap信封,在我看来soap请求没有正确的命名空间。任何人都可以建议我
我想安装一个带有一些身份验证的私有(private)Rubygem服务器。我希望能够使用公共(public)Ubuntu服务器托管内部gem。我读到了http://docs.rubygems.org/read/chapter/18.但是那个没有身份验证-如我所见。然后我读到了https://github.com/cwninja/geminabox.但是当我使用基本身份验证(他们在他们的Wiki中有)时,它会提示从我的服务器获取源。所以。如何制作带有身份验证的私有(private)Rubygem服务器?这是不可能的吗?谢谢。编辑:Geminabox问题。我尝试“捆绑”以安装新的gem..
exe应该在我打开页面时运行。异步进程需要运行。有什么方法可以在ruby中使用两个参数异步运行exe吗?我已经尝试过ruby命令-system()、exec()但它正在等待过程完成。我需要用参数启动exe,无需等待进程完成是否有任何rubygems会支持我的问题? 最佳答案 您可以使用Process.spawn和Process.wait2:pid=Process.spawn'your.exe','--option'#Later...pid,status=Process.wait2pid您的程序将作为解释器的子进程执行。除
最近,当我启动我的Rails服务器时,我收到了一长串警告。虽然它不影响我的应用程序,但我想知道如何解决这些警告。我的估计是imagemagick以某种方式被调用了两次?当我在警告前后检查我的git日志时。我想知道如何解决这个问题。-bcrypt-ruby(3.1.2)-better_errors(1.0.1)+bcrypt(3.1.7)+bcrypt-ruby(3.1.5)-bcrypt(>=3.1.3)+better_errors(1.1.0)bcrypt和imagemagick有关系吗?/Users/rbchris/.rbenv/versions/2.0.0-p247/lib/ru
在Rails4.0.2中,我使用s3_direct_upload和aws-sdkgems直接为s3存储桶上传文件。在开发环境中它工作正常,但在生产环境中它会抛出如下错误,ActionView::Template::Error(noimplicitconversionofnilintoString)在View中,create_cv_url,:id=>"s3_uploader",:key=>"cv_uploads/{unique_id}/${filename}",:key_starts_with=>"cv_uploads/",:callback_param=>"cv[direct_uplo
我有一个服务模型/表及其注册表。在表单中,我几乎拥有服务的所有字段,但我想在验证服务对象之前自动设置其中一些值。示例:--服务Controller#创建Action:defcreate@service=Service.new@service_form=ServiceFormObject.new(@service)@service_form.validate(params[:service_form_object])and@service_form.saverespond_with(@service_form,location:admin_services_path)end在验证@ser
我是Google云的新手,我正在尝试对其进行首次部署。我的第一个部署是RubyonRails项目。我基本上是在关注thisguideinthegoogleclouddocumentation.唯一的区别是我使用的是我自己的项目,而不是他们提供的“helloworld”项目。这是我的app.yaml文件runtime:customvm:trueentrypoint:bundleexecrackup-p8080-Eproductionconfig.ruresources:cpu:0.5memory_gb:1.3disk_size_gb:10当我转到我的项目目录并运行gcloudprevie
我想在Ruby中创建一个用于开发目的的极其简单的Web服务器(不,不想使用现成的解决方案)。代码如下:#!/usr/bin/rubyrequire'socket'server=TCPServer.new('127.0.0.1',8080)whileconnection=server.acceptheaders=[]length=0whileline=connection.getsheaders想法是从命令行运行这个脚本,提供另一个脚本,它将在其标准输入上获取请求,并在其标准输出上返回完整的响应。到目前为止一切顺利,但事实证明这真的很脆弱,因为它在第二个请求上中断并出现错误:/usr/b
您如何在Rails中的实时服务器上进行有效调试,无论是在测试版/生产服务器上?我试过直接在服务器上修改文件,然后重启应用,但是修改好像没有生效,或者需要很长时间(缓存?)我也试过在本地做“脚本/服务器生产”,但是那很慢另一种选择是编码和部署,但效率很低。有人对他们如何有效地做到这一点有任何见解吗? 最佳答案 我会回答你的问题,即使我不同意这种热修补服务器代码的方式:)首先,你真的确定你已经重启了服务器吗?您可以通过跟踪日志文件来检查它。您更改的代码显示的View可能会被缓存。缓存页面位于tmp/cache文件夹下。您可以尝试手动删除
rails中是否有任何规定允许站点的所有AJAXPOST请求在没有authenticity_token的情况下通过?我有一个调用Controller方法的JqueryPOSTajax调用,但我没有在其中放置任何真实性代码,但调用成功。我的ApplicationController确实有'request_forgery_protection'并且我已经改变了config.action_controller.consider_all_requests_local在我的environments/development.rb中为false我还搜索了我的代码以确保我没有重载ajaxSend来发送