简体   繁体   English

如何将PHP客户端连接到Java Web服务?

[英]How to connect php client to java webservice?

I know php webservice SOAP,json,rest etc, but I am new for java webservice. 我知道php webservice SOAP,json,rest等,但是我是java webservice的新手。 Now I want to get php client to java webservice. 现在,我想将php客户端安装到java webservice。 What is the best way to do this? 做这个的最好方式是什么?

There is nothing new in it. 没有什么新鲜的了。 Just create SoapClient with java web services WSDL URL and call it's method: 只需使用Java Web服务WSDL URL创建SoapClient并调用它的方法:

<?php
try{
    $proxy = new SoapClient("javaWsdlUrl?wsdl");
    $result = $proxy->javaWSMethod(array("arg0"=>"1234","arg1"=>"5678"));
    print_r($result);
} catch (Exception $e) {
    echo $e->getMessage ();
}
?>

Other things will be same like generating stubs, getting method names,... 其他事情将与生成存根,获取方法名称等相同。

When you connnect to a public webservice like Amazon, you dont (necesserly) know what language is used to create the webservice (server side) . 当您连接到Amazon之类的公共Web服务时,您(不必)不知道使用哪种语言创建Web服务(服务器端)。 So you will connect to your java webservice the same way you connect to a php or any other webservice. 因此,您将以连接到php或任何其他网络服务的相同方式连接到Java网络服务。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM