我正在尝试将参数传递给类构造函数,但没有成功。我尝试了以下方法
.PHP
$c = "site.wsdl";
$client = new SoapClient($c,array('classmap' => array('state' => "mystate",'county' => "mycounty")),array("trace"=> 1,"exceptions" => 1));
$client = new SoapClient($c,array('classmap' => array('state' => "mystate",'county' => "mycounty")));
$client = new SoapClient($c,array('state' => "mystate",'county'=>"mycounty"));
网络服务代码 Java
@WebService
public class MyWebservice{
String test = "";
/**
*
* @param county
* @param state
*/
public MyWebservice(@WebParam(name = "county") String county,
@WebParam(name = "state") String state) {
test= county+"_"+state;
//want to use this String elsewhere in the class
}
}
错误
Fatal error: Uncaught SoapFault exception: [S:Server] com.sun.enterprise.container.common.spi.util.InjectionException: Error creating managed object for class
如果我从构造函数中删除参数,我在创建 soap 客户端时没有任何问题。
谢谢你的帮助。
你应该
映射到php类(通过提供一个带有它们名称的字符串),而这些类又被用来将参数转发到远程URI,我的印象是你正在使用classmap作为尝试直接发送参数的一种方式。如果没有,可以发布您的mycountry和mystate类以及wsdl文件。
您将在这篇博文中找到有关如何将SoapClient与classmap一起使用的非常详细的示例(不是我的),这很清楚,我建议您仔细阅读一次以确保这不是问题。希望对您有所帮助。:)