打开APP
userphoto
未登录

开通VIP,畅享免费电子书等14项超值服

开通VIP
jsp中调用webservice 代码
service类:

public String sayHello()

{

    
return "Hello world!";

   }

调用方法如下:

////////////////////////////此方法调用webservice的方法,返回值/////////////////////////////////////

  public String getString()
     
{
          String ret
= null;
         
try
         
{
              String endpoint
=
                     
"http://localhost:8080/LSA/services/test";
              Service service
= new Service();
              Call call
= null;
              call
= (Call) service.createCall();
              call.setOperationName(
new QName(
                     
"http://localhost:8080/LSA/services/test",
                     
"sayHello"));
              call.setTargetEndpointAddress(
new java.net.URL(endpoint));
              ret
=(String)call.invoke(new Object[]
{});

          }
catch(Exception e)
         
{
              e.printStackTrace();
          }

         
return ret;
      }

/////////////////////////////////////END//////////////////////////////////////////////

调用带参数的webservice

public void getString()
     
{
          String ret
= null;
         
try
         
{
              String endpoint
=
                     
"http://localhost:8083/Receive/services/AddUser";

              Service   service
= new Service();
              Call call
= null;
              call
= (Call) service.createCall();
              call.setOperationName(
new QName(
                     
"http://localhost:8083/Receive/services/AddUser",
                     
"AddUser"));
              call.addParameter(
"BH",org.apache.axis.encoding.XMLType.XSD_STRING,javax.xml.rpc.ParameterMode.IN);
              call.addParameter(
"MM",org.apache.axis.encoding.XMLType.XSD_STRING,javax.xml.rpc.ParameterMode.IN);

             
//call.invoke("1");

              call.setTargetEndpointAddress(
new java.net.URL(endpoint));
              ret
=(String)call.invoke(new Object[]
{"2","2"});


          }
catch(Exception e)
         
{
              e.printStackTrace();
          }

         
//return ret;
      }


本站仅提供存储服务,所有内容均由用户发布,如发现有害或侵权内容,请点击举报
打开APP,阅读全文并永久保存 查看更多类似文章
猜你喜欢
类似文章
JAVA6开发WebService (一)
关于Webservice接口对接相关总结
spring事务回滚问题
JR - 精品文章 - AXIS学习笔记(一)
如何使用Axis开发Webservice应用程序
C#实现WebService上传下载文件
更多类似文章 >>
生活服务
热点新闻
分享 收藏 导长图 关注 下载文章
绑定账号成功
后续可登录账号畅享VIP特权!
如果VIP功能使用有故障,
可点击这里联系客服!

联系客服