0
回答
java调用webservice报400错误,请大神赐教
滴滴云服务器,限时包月0.9元,为开发者而生>>>   

java调用webservice报400错误:

第一次接触webservice,表示技术能力有限,soapui连接是正常的,搞了好久没有搞定,来求救各位大神

代码:

import java.net.MalformedURLException;
import java.net.URL;
import java.rmi.RemoteException;

import javax.xml.namespace.QName;
import javax.xml.rpc.ParameterMode;
import javax.xml.rpc.ServiceException;

import org.apache.axis.client.Call;
import org.apache.axis.client.Service;
import org.apache.axis.encoding.XMLType;

public class TestDemo {
	 private String userName = "userName";
	 private String userPass = "userPass";
	 public String invokeRemoteFuc()  {
	        String url="http://www.domain.com:50000/dir/wsdl?p=sa/c56619d3ba1964c73e";
		    String result="noresult";
	        String namespace="http://www.domain.com";
	        Service service =new Service();
	        Call call;
	        Object[] object=new Object[1]; 
	        object[0]="testdemo"; 
	        try {
	            call=(Call)service.createCall();
	            call.setTargetEndpointAddress(new URL(url));
	            call.setOperationName(new QName(namespace,"SI_TASK_LIST_OUT"));
	            call.setUsername(userName);
	            call.setPassword(userPass);
//	            call.addHeader(new SOAPHeaderElement("Authorization","username",userName));
//	            call.addHeader(new SOAPHeaderElement("Authorization","password",userPass));
	            call.addParameter(new  QName(namespace,"USER_ID"), XMLType.XSD_STRING,  ParameterMode.IN);
	            //设置返回值类型:
	            call.setReturnType(XMLType.XSD_STRING);   //返回值类型:String
	            result=(String)call.invoke(object);  //远程调用
	            
	        } catch (MalformedURLException e) {
				e.printStackTrace();
			} catch (RemoteException e) {
				e.printStackTrace();
			} catch (ServiceException e) {
				e.printStackTrace();
			}
	        return result;
	    }

	    public static void main(String[] args){
	    	Test t=new Test();
	        String result =t.invokeRemoteFuc();
	        System.out.println(result);
	    }

}

错误信息:

<无标签>
举报
程序员小贝
发帖于5个月前 0回/47阅
顶部