如何使用SOAP将对象从PHP发送到JavaWeb服务?

如何使用SOAP将对象从PHP发送到JavaWeb服务?,java,php,web-services,soap,soap-client,Java,Php,Web Services,Soap,Soap Client,我有一个正在运行的web服务(使用EclipseLink作为JPA提供者),并且希望调用使用SOAP从PHP更新数据库中数据的方法 web服务中的方法可能如下所示: public void updatePerson(Person p){ EntityManagerFactory emf = Persistence.createEntityManagerFactory("PersonLib"); EntityManager em = emf.createEntityManager();

我有一个正在运行的web服务(使用EclipseLink作为JPA提供者),并且希望调用使用SOAP从PHP更新数据库中数据的方法

web服务中的方法可能如下所示:

public void updatePerson(Person p){
   EntityManagerFactory emf = Persistence.createEntityManagerFactory("PersonLib");
   EntityManager em = emf.createEntityManager();
   if(!em.getTransaction().isActive()) {
      em.getTransaction().begin();
   }
   em.merge(p);
   em.getTransaction().commit();
}
从PHP中,我想我必须创建一个类型为
stdClass
的对象,并将其作为Person的参数发送。我说得对吗?但我不认为这些代码行能起作用:

$client = new SoapClient("url.to.wsdl", array("trace" => 1));
$obj = new stdClass();
$obj->Person = new stdClass(); 
$obj->Person->personId = 1;
$obj->Person->name = "Peter";
$client->updatePerson($obj);

我不知道这是否是将对象从PHP发送到Java的正确方法(它在Java应用程序中调用方法updatePerson(Person p),但p不包含我在PHP中输入的数据)。

如果可能,请向我们展示WSDL文件

通常,在PHP中使用SoapClient时,即使web服务需要对象,我也会使用数组,因此,与其创建新的stdClass,不如尝试发送以下数组:

$client = new SoapClient("url.to.wsdl");
$obj    = new array("personId" => 1, "name" => "Peter");

$client->updatePerson($obj);
这将向对象发送所需的数据


希望有帮助。

你能给我们看看你的WSDL吗?另外,您可能还想检查在
SoapClient
构造函数中使用选项
“classmap”
的示例。我几天前就让它工作了。但是我没有,我可以发送一个数组而不是stdClass!类型的对象:-)谢谢你!