|
|
马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。如果您注册时有任何问题请联系客服QQ: 83569622 。
您需要 登录 才可以下载或查看,没有帐号?注册
x
本帖最后由 ygj26 于 2013/4/25 13:23 编辑
太久没关注这里,看到有很多人浏览这个贴子,结一下贴。
使用axis生成客户端代码再调用会简单很多,原始的方法往往可能因一些配置或代码写的不到位而无法使用。
http://axis.apache.org/axis/
下面的内容可以不看了。- package com.ygj.webservice;
- public class HelloService {
- public String sayHello() {
- return "hello";
- }
- public String sayHello(String name) {
- if(name == null || name.equals("")) {
- name = "nobody";
- }
- return "Hello, " + name;
- }
- }
复制代码 以上是我自己开发的一个测试类,发布成Webservice后,通过客户端程序能正常调用,客户端程序如下:- package test;
- import java.net.MalformedURLException;
- import java.net.URL;
- import java.rmi.RemoteException;
- import javax.xml.rpc.ServiceException;
- import org.apache.axis.client.Call;
- import org.apache.axis.client.Service;
- public class HelloServiceTest {
- public static void main(String[] args) {
- try {
- System.out.println("Begin......");
- Service service = new Service();
- Call call = (Call) service.createCall();
- call.setTargetEndpointAddress(new URL("http://localhost:9704/axis_webservice/services/HelloServices?wsdl"));
- call.setOperationName("sayHello");
- call.addParameter("name", org.apache.axis.Constants.XSD_STRING, javax.xml.rpc.ParameterMode.IN);
- call.setReturnType(org.apache.axis.Constants.XSD_STRING);
- try {
- String ret = (String) call.invoke(new Object[] {"张三"});
- System.out.println("The return value is:" + ret);
- } catch (RemoteException e) {
- e.printStackTrace();
- }
- } catch (ServiceException e) {
- e.printStackTrace();
- } catch (MalformedURLException e) {
- e.printStackTrace();
- }
- }
- }
复制代码 输出结果为:Hello,张三
BIEE提供的Webservice中有方法:
String logon(String username, String password)
我的程序客户端调用程序如下:- package test;
- import java.net.MalformedURLException;
- import java.net.URL;
- import java.rmi.RemoteException;
- import javax.xml.namespace.QName;
- import javax.xml.rpc.ServiceException;
- import org.apache.axis.client.Call;
- import org.apache.axis.client.Service;
- public class BieeWebServiceTest {
- public static void main(String[] args) {
- try {
- System.out.println("Begin......");
- Service service = new Service();
- Call call = (Call) service.createCall();
- call.setTargetEndpointAddress(new URL("http://localhost:9704/analytics/saw.dll?wsdl"));
- call.setOperationName(new QName("com.siebel.analytics.web/soap/v5", "logon"));
- call.addParameter("username", org.apache.axis.Constants.XSD_STRING, javax.xml.rpc.ParameterMode.IN);
- call.addParameter("password", org.apache.axis.Constants.XSD_STRING, javax.xml.rpc.ParameterMode.IN);
- call.setReturnType(org.apache.axis.Constants.XSD_STRING);
- try {
- String ret = (String) call.invoke(new Object[] {"Administrator", "Administrator"});
- System.out.println("The return value is:" + ret);
- } catch (RemoteException e) {
- e.printStackTrace();
- }
- } catch (ServiceException e) {
- e.printStackTrace();
- } catch (MalformedURLException e) {
- e.printStackTrace();
- }
- }
复制代码 可是却报出错误:
AxisFault
faultCode: {http://xml.apache.org/axis/}HTTP
faultSubcode:
faultString: (400)Bad Request
faultActor:
faultNode:
faultDetail:
{}:return code: 400
{http://xml.apache.org/axis/}HttpErrorCode:400
(400)Bad Request
at org.apache.axis.transport.http.HTTPSender.readFromSocket(HTTPSender.java:744)
at org.apache.axis.transport.http.HTTPSender.invoke(HTTPSender.java:144)
at org.apache.axis.strategies.InvocationStrategy.visit(InvocationStrategy.java:32)
at org.apache.axis.SimpleChain.doVisiting(SimpleChain.java:118)
at org.apache.axis.SimpleChain.invoke(SimpleChain.java:83)
at org.apache.axis.client.AxisClient.invoke(AxisClient.java:165)
at org.apache.axis.client.Call.invokeEngine(Call.java:2784)
at org.apache.axis.client.Call.invoke(Call.java:2767)
at org.apache.axis.client.Call.invoke(Call.java:2443)
at org.apache.axis.client.Call.invoke(Call.java:2366)
at org.apache.axis.client.Call.invoke(Call.java:1812)
at test.BieeWebServiceTest.main(BieeWebServiceTest.java:27)
试了很多办法了,望高人能够指点,我的目的是能够调BIEE的Webservice,所以问题不局限于此,仅打个比方,有做过这方面的,还请多多帮忙!!
另外我也试过本论坛提供下载的 Java集成BIEE源代码,使用其提供的SAWSessionServiceSoapProxy也不能做到。请高人指教!!
谢谢!!
|
|