• 博客园logo
  • 会员
  • 众包
  • 新闻
  • 博问
  • 闪存
  • 赞助商
  • HarmonyOS
  • Chat2DB
    • 搜索
      所有博客
    • 搜索
      当前博客
  • 写随笔 我的博客 短消息 简洁模式
    用户头像
    我的博客 我的园子 账号设置 会员中心 简洁模式 ... 退出登录
    注册 登录
gooliugle
博客园    首页    新随笔    联系   管理    订阅  订阅
java 调用.net web service

代码:

 

import javax.xml.namespace.QName;
import org.apache.axis.client.Call;
import org.apache.axis.client.Service;

public class IPreventIndulge {
    
public boolean getValidateInfo(String UUid) {
        
try {
        String endpoint 
= " http://game.qidian.com/RemoteWebService/IPreventIndulge.asmx";    
                    
// 创建一个服务(service)调用(call)     
                    Service service = new Service();    
                    Call call 
= (Call) service.createCall();// 通过service创建call对象     
                    
// 设置service所在URL    
                    call.setTargetEndpointAddress(new java.net.URL(endpoint));   
                    call.setUseSOAPAction(
true); 
                    call.setSOAPActionURI(
" http://tempuri.org/GetIndulgeInfo"); //这个也要注意 就是要加上要调用的方法Add,不然也会报错
                    call.setOperationName(new QName(" http://tempuri.org/","GetIndulgeInfo")); 
                    
//GetIndulgeInfo  方法名称
                    call.addParameter(new QName(" http://tempuri.org/","idType"),
                            org.apache.axis.encoding.XMLType.XSD_STRING,
                           javax.xml.rpc.ParameterMode.IN);
                   call.addParameter(
new QName(" http://tempuri.org/","UUId"), 
                           org.apache.axis.encoding.XMLType.XSD_STRING,
                           javax.xml.rpc.ParameterMode.IN);

                    call.setReturnType(org.apache.axis.encoding.XMLType.SOAP_STRING); 
//返回参数的类型
                   
                    
                    
// Object 数组封装了参数,参数为"This is Test!",调用processService(String arg)     
                    String ret = (String) call.invoke(new Object[] {UUid,"0"});    
                    System.out.println(ret);  
        } 
catch (Exception e) {
            e.printStackTrace();
        }  
        
return false;
    }
    
public static void main(String[] args) {
        
new IPreventIndulge().getValidateInfo("411668171");
    }
}

 

posted on 2011-04-25 17:53  gooliugle  阅读(519)  评论(0)    收藏  举报
刷新页面返回顶部
博客园  ©  2004-2025
浙公网安备 33010602011771号 浙ICP备2021040463号-3