- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
"http://hostnam-6ren">
这段简短的 php 代码在 java 中等效于什么?
$client = new SoapClient(NULL,
array(
"location" => "http://hostname:port/')",
"uri" => "urn:String",
"style" => SOAP_RPC,
'login' => "soapuser",
'password' => "soappass",
)
);
$command = "This command will be sent to SOAP";
try {
$result = $client->executeCommand(new SoapParam($command, "command"));
return true;
}
catch (Exception $e) {
return false;
}
是否有可能使用一个简短的 java 类实现相同的结果?
最佳答案
更新 2我可能不明白你的问题。 (你能提供你的服务的 wdsl 吗?)创建一个像你的 php 代码一样的客户端:
使用:
package com.mkyong.client;
import java.net.URL;
import javax.xml.namespace.QName;
import javax.xml.ws.Service;
import com.mkyong.ws.HelloWorld;
public class HelloWorldClient{
public static void main(String[] args) throws Exception {
URL url = new URL("http://localhost:9999/ws/hello?wsdl");
//1st argument service URI, refer to wsdl document above
//2nd argument is service name, refer to wsdl document above
QName qname = new QName("http://ws.mkyong.com/", "HelloWorldImplService");
Service service = Service.create(url, qname);
HelloWorld hello = service.getPort(HelloWorld.class);
System.out.println(hello.getHelloWorldAsString("mkyong"));
}
}
将此文件复制到 com/mkyong/client。要编译使用 javac com/mkyong/client/HelloWorldClient.java
并使用 java com/mkyong/client/HelloWorldClient
运行,另请参阅:Compiling four java files within one package using javac和 making a java package in the command line
“映射”到您的 php 示例 http://localhost:9999/ws/hello?wsdl
将等同于 http://hostname:port/
和 executeCommand
将与 hello.getHelloWorldAsString
相同。
更新试试 JAX-WS ( http://jax-ws.java.net/ )
来自 http://www.mkyong.com/webservices/jax-ws/jax-ws-hello-world-example/ :
package com.mkyong.ws;
import javax.jws.WebMethod;
import javax.jws.WebService;
import javax.jws.soap.SOAPBinding;
import javax.jws.soap.SOAPBinding.Style;
//Service Endpoint Interface
@WebService
@SOAPBinding(style = Style.RPC)
public interface HelloWorld{
@WebMethod String getHelloWorldAsString(String name);
}
除了这里的答案:Working Soap client example你可以找到很多教程,告诉你如何用 java 编写 soap 客户端:
关于java - 如何通过 JAVA 中的 SoapClient 运行命令,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18680384/
以下所有内容都在 Amazon EC2 中运行 几个月来我一直在使用 ExactTarget 的 API 发送电子邮件,但它在我的 QA 环境中停止工作了。以下所有代码在我的生产环境中都能正常工作。他
我需要将 PHP 的 SoapClient 与 myfile-ca.crt 一起使用。我如何告诉 SoapClient 构造函数使用客户端证书(crt 文件)? 我熟悉 php SoapClient,
我以这种方式向 WSDL 服务器发送请求: $soap = new SoapClient('WSDL_URI'); $soap->SomeFunction(array('Param1' => 123,
我正在使用带有 WSDL 的 PHP Soap 客户端来发送 SOAP 请求。 这就是我初始化 SoapClient 的方式: $options = [ "trace" => 1,
我正在拔头发。我尝试了很多不同的方法,但没有任何效果: 'localhost', 'proxy_port' => '8888' )); try { $test = new stdCl
这个问题在这里已经有了答案: Does this SOAP Fault mean what I think it means? (3 个答案) 关闭 8 年前。 除了这条错误信息,这里没什么可写的了
我正在尝试从运行该服务的同一台服务器上调用 Soap 客户端以进行测试。我的 WSDL 在:http://www.installittoday.com/api/server.php?wsdl我正在尝试
这个问题在这里已经有了答案: Does this SOAP Fault mean what I think it means? (3 个答案) 关闭 8 年前。 除了这条错误信息,这里没什么可写的了
我正在尝试从运行该服务的同一台服务器上调用 Soap 客户端以进行测试。我的 WSDL 在:http://www.installittoday.com/api/server.php?wsdl我正在尝试
我们需要连接的其中一个 WS 有 PHP 示例代码。他们为我们签署了 CSR ...所以我们现在有用于身份验证的私钥和证书。 他们建议将私钥和签名证书放入一个 .pem 文件,并在 PHP 中使用如下
我在 PhP 中有一个工作的soaprequest,我正在尝试创建一个需要相同调用的java程序,但是我真的很难找到在java中创建以下php代码的方法,我找到了许多网站解释java中的soap请求,
我创建新的 SoapClient $this->soap = new \SoapClient($this->wdls // WDLS with corect host , [ 'excepti
我有一个 Web 服务函数,它向 PHP 客户端返回一组项目。根据项目的数量,PHP 返回类型不同。如果函数返回一项,则 PHP 类型为 stdClass 如果函数返回多项,则 PHP 类型为 arr
我有一个 WSDL,它有一个需要属性的元素: Claim Element 就生成的 xml 而言,它应该如下所示:
我正在使用 SOAP 集成支付网关。当我使用 Wamp 调用服务功能时,它运行良好。但是在我的实时服务器上它给出了以下错误 - Class 'SoapClient' not found 我使用的代码是
我找到了许多关于 SoapClient 希望您如何在请求中设置属性的解释,但我就是找不到从响应中读取属性的方法。 例如,我的 SoapClient 响应中包含以下元素: ... JOWtest
当我发送以下请求时,出现“版本错误”异常。 上面的请求被转换成zend代码 $client = new zend_soap_client(null,
我是 web 服务的新手,我正在尝试使用 soapClient() 调用 web 服务,它生成的请求 XML 不是预期的格式 下面是请求XML的预期格式 MD
另一个 SOAP 问题 - 我有一个大的多维数组,当使用 print_r 时回显很好(例如,您可以看到所有数据)。当我使用 时出现问题 SOAPClient->__soapCall('Function
我最近从 PHP5.4 升级到 PHP7。天哪,这是一个变化,但这不是重点。 升级后我遇到了 SoapService 的问题。 这是我的 SoapRequest 在 PHP5.4 上的样子:
我是一名优秀的程序员,十分优秀!