我有一个包含三种方法的 WCF 服务。其中两个方法返回自定义类型(这些按预期工作),第三个方法将自定义类型作为参数并返回一个 bool 值。当通过 PHP soap 客户端调用第三个方法时,它会返回“对象引用未设置为对象的实例”异常。
示例自定义类型:
_ 公开课MyClass
Private _propertyA As Double
<DataMember()> _
Public Property PropertyA() As Double
Get
Return _propertyA
End Get
Set(ByVal value As Double)
_propertyA = value
End Set
End Property
Private _propertyB As Double
<DataMember()> _
Public Property PropertyB() As Double
Get
Return _propertyB
End Get
Set(ByVal value As Double)
_propertyB = value
End Set
End Property
Private _propertyC As Date
<DataMember()> _
Public Property PropertyC() As Date
Get
Return _propertyC
End Get
Set(ByVal value As Date)
_propertyC = value
End Set
End Property
下课
方法:
公共(public)函数 Add(ByVal param As MyClass) As Boolean Implements IService1.Add ' ... 结束函数
PHP 客户端调用:
$client->Add(array('param'=>array( '属性A' => 1, '属性B'=> 2, 'PropertyC' => "2009-01-01" )));
WCF 服务在 .Net 客户端上运行良好,但我是 PHP 新手,无法正常运行。
是否可以在 PHP 中创建“MyClass”的实例。
如有任何帮助,我们将不胜感激。
注意:我使用的是 PHP 5(适用于 Windows 的 XAMPP 1.7.0)。
谢谢
马特
最佳答案
为了测试,我不再设置 XAMPP,但这里有一些示例代码:
PHP:
$wsdl = "https://....../ServiceName.svc?wsdl";
$endpoint = "https://...../ServiceName.svc/endpointName";
$client = new SoapClient($wsdl, array('location'=>$endpoint));
$container = new stdClass();
$container->request->PropertyA = 'Test 1';
$container->request->PropertyB = 'Test 2';
$container->request->PropertyC = '05/10/2010';
$response = $client->ServiceMethodA($container);
request 是网络服务期望的参数名称。
如果您有一个引用了其他自定义类型的自定义类型,您可以按如下方式设置这些属性:
$container->request->OtherCustomType->Property1 = 'Test';
希望对您有所帮助。
关于.net - 带有 PHP 客户端的 WCF 服务 - 复杂类型作为参数不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/488497/
作为我的Rails应用程序的一部分,我编写了一个小导入程序,它从我们的LDAP系统中吸取数据并将其塞入一个用户表中。不幸的是,与LDAP相关的代码在遍历我们的32K用户时泄漏了大量内存,我一直无法弄清楚如何解决这个问题。这个问题似乎在某种程度上与LDAP库有关,因为当我删除对LDAP内容的调用时,内存使用情况会很好地稳定下来。此外,不断增加的对象是Net::BER::BerIdentifiedString和Net::BER::BerIdentifiedArray,它们都是LDAP库的一部分。当我运行导入时,内存使用量最终达到超过1GB的峰值。如果问题存在,我需要找到一些方法来更正我的代
我有一些Ruby代码,如下所示:Something.createdo|x|x.foo=barend我想编写一个测试,它使用double代替block参数x,这样我就可以调用:x_double.should_receive(:foo).with("whatever").这可能吗? 最佳答案 specify'something'dox=doublex.should_receive(:foo=).with("whatever")Something.should_receive(:create).and_yield(x)#callthere
是的,我知道最好使用webmock,但我想知道如何在RSpec中模拟此方法:defmethod_to_testurl=URI.parseurireq=Net::HTTP::Post.newurl.pathres=Net::HTTP.start(url.host,url.port)do|http|http.requestreq,foo:1endresend这是RSpec:let(:uri){'http://example.com'}specify'HTTPcall'dohttp=mock:httpNet::HTTP.stub!(:start).and_yieldhttphttp.shou
对于作为String#tr参数的单引号字符串文字中反斜杠的转义状态,我觉得有些神秘。你能解释一下下面三个例子之间的对比吗?我特别不明白第二个。为了避免复杂化,我在这里使用了'd',在双引号中转义时不会改变含义("\d"="d")。'\\'.tr('\\','x')#=>"x"'\\'.tr('\\d','x')#=>"\\"'\\'.tr('\\\d','x')#=>"x" 最佳答案 在tr中转义tr的第一个参数非常类似于正则表达式中的括号字符分组。您可以在表达式的开头使用^来否定匹配(替换任何不匹配的内容)并使用例如a-f来匹配一
我目前正在使用以下方法获取页面的源代码:Net::HTTP.get(URI.parse(page.url))我还想获取HTTP状态,而无需发出第二个请求。有没有办法用另一种方法做到这一点?我一直在查看文档,但似乎找不到我要找的东西。 最佳答案 在我看来,除非您需要一些真正的低级访问或控制,否则最好使用Ruby的内置Open::URI模块:require'open-uri'io=open('http://www.example.org/')#=>#body=io.read[0,50]#=>"["200","OK"]io.base_ur
1.错误信息:Errorresponsefromdaemon:Gethttps://registry-1.docker.io/v2/:net/http:requestcanceledwhilewaitingforconnection(Client.Timeoutexceededwhileawaitingheaders)或者:Errorresponsefromdaemon:Gethttps://registry-1.docker.io/v2/:net/http:TLShandshaketimeout2.报错原因:docker使用的镜像网址默认为国外,下载容易超时,需要修改成国内镜像地址(首先阿里
当我创建一个Rails应用程序时,控制台:railsnewfoo我的代码可以使用字符串“foo”吗?puts"Yourapp'snameis"+app_name_bar 最佳答案 Rails.application.class将为您提供应用程序的全名(例如YourAppName::Application)。从那里您可以使用Rails.application.class.parent获取模块名称。 关于ruby-on-rails-应用程序的名称是否可以作为变量使用?,我们在StackOve
使用rspec-rails3.0+,测试设置分为spec_helper和rails_helper我注意到生成的spec_helper不需要'rspec/rails'。这会导致zeus崩溃:spec_helper.rb:5:in`':undefinedmethod`configure'forRSpec:Module(NoMethodError)对thisissue最常见的回应是需要'rspec/rails'。但这是否会破坏仅使用spec_helper拆分rails规范和PORO规范的全部目的?或者这无关紧要,因为Zeus无论如何都会预加载Rails?我应该在我的spec_helper中做
我在搜索我的值是方法的散列时遇到问题。我只是不想运行plan_type与键匹配的方法。defmethod(plan_type,plan,user){foo:plan_is_foo(plan,user),bar:plan_is_bar(plan,user),waa:plan_is_waa(plan,user),har:plan_is_har(user)}[plan_type]end目前如果我传入“bar”作为plan_type,所有方法都会运行,我怎么能只运行plan_is_bar方法呢? 最佳答案 这个变体怎么样?defmethod
我在加密来self正在使用的第三方供应商的值时遇到问题。他们的指令如下:1)Converttheencryptionpasswordtoabytearray.2)Convertthevaluetobeencryptedtoabytearray.3)Theentirelengthofthearrayisinsertedasthefirstfourbytesontothefrontofthefirstblockoftheresultantbytearraybeforeencryption.4)EncryptthevalueusingAESwith:1.256-bitkeysize,2.25