Java开发网 Java开发网
注册 | 登录 | 帮助 | 搜索 | 排行榜 | 发帖统计  

您没有登录

» Java开发网 » WebService/XML/JSON/SOAP/SOA  

按打印兼容模式打印这个话题 打印话题    把这个话题寄给朋友 寄给朋友    该主题的所有更新都将Email到你的邮箱 订阅主题
flat modethreaded modego to previous topicgo to next topicgo to back
作者 [求助] 编译通过,运行出错SOAPException
my_rob





发贴: 3
积分: 0
于 2005-10-14 13:30 user profilesend a private message to usersearch all posts byselect and copy to clipboard. 
ie only, sorry for netscape users:-)add this post to my favorite list
在调用call.invoke时出错
invoke的原型
public response Call.invoke(java.net.URL url, java.lang.String SOAPActionURI);

查资料有注释:
note that the action URI is empty because the XML-SOAP rpc router does not need this. This may change in the future
不知道现在这个URI要怎么写?

设定 SOAPActionURI="urn:getMessage" 问题依然如故

环境
windowsXP console
jdk 1.4
tomcat 5.0.28
soap 2.3.1

// HelloWorldService.java
public class HelloWorldService {
static String str = "Hello World!";
public String getMessage() {
return str;
}
}

// HelloWorldClient.java

import org.apache.soap.Constants;
import java.net.URL;
import org.apache.soap.Fault;
import org.apache.soap.rpc.Call;
import org.apache.soap.rpc.Response;
import org.apache.soap.rpc.Parameter;

public class HelloWorldClient {
static String DEFAULT_ENDPOINT = "http://localhost:8080/soap/servlet/rpcrouter";
public static void main(String args[]) throws Exception {
String endPoint = DEFAULT_ENDPOINT;

// Process Arguments
System.out.println("Arguments");
if (args.length == 1) {
endPoint = args[0];
}
else if (args.length > 1) {
System.out.println("java HelloWorldClient [endpoint]");
}

// Build the SOAP RPC request message using the Call object
System.out.println("Build the SOAP RPC request message");
Call call = new Call();
call.setTargetObjectURI("urn:HelloWorldService");
call.setMethodName("getMessage");
call.setEncodingStyleURI(Constants.NS_URI_SOAP_ENC);

// Create a URL object, which represents the endpoint
System.out.println("Create URL");
URL url = new URL(endPoint);

// Send the SOAP RPC request message using invoke() method
System.out.println("Send the SOAP RPC request message");
Response resp = call.invoke(url, "");

// Check the response
System.out.println("Check repsonse");
if (resp.generatedFault()) {
Fault fault = resp.getFault();
System.out.println("The Following Error Occured:");
System.out.println(" Fault Code = " + fault.getFaultCode());
System.out.println(" Fault String = " + fault.getFaultString());
}
else {
Parameter result = resp.getReturnValue();
System.out.println(result.getValue());
}
}
}

运行信息:见图




话题树型展开
人气 标题 作者 字数 发贴时间
7857 [求助] 编译通过,运行出错SOAPException my_rob 2298 2005-10-14 13:30

flat modethreaded modego to previous topicgo to next topicgo to back
  已读帖子
  新的帖子
  被删除的帖子
Jump to the top of page

   Powered by Jute Powerful Forum® Version Jute 1.5.6 Ent
Copyright © 2002-2021 Cjsdn Team. All Righits Reserved. 闽ICP备05005120号-1
客服电话 18559299278    客服信箱 714923@qq.com    客服QQ 714923