各位专家,两天前,我想从eclipse(JAVA)调用比亚迪webservice,所以我在我的测试系统中尝试了一下,没问题。现在我和大家分享一下我的经验,我很感激你的评论。1.准备比亚迪系统的webservice,比如选择webservice"querysupplierin1",创建通信场景和通信安排。2.在soapUI中测试webservice,数据更新,也许不需要,但我想确认webservice是否正常工作。使用Raw参数和XML参数,运行时就可以了。3.通过eclipse(JAVA)调用比亚迪webservice,我使用httpClient,代码如下:导入java.io.IOException异常;导入输入流;导入org.apache.commons网站.httpclient.httpclient文件;导入org.apache.commons网站.httpclient.methods.PostMethod方法;导入org.apache.commons网站.httpclient.methods.RequestEntity;导入org.apache.commons网站.httpclient.methods.StringRequestEntity;导入组织.jsoup.jsoup;导入org.jsoup.nodes节点.Document;
公共类CallBYDQuerysupplier{
公共字符串invokeRemoteFuc(){
//POST郾,trustdata大数据,淘客返利,功String result="没有结果!";
//XML参数String soapRequestData=""+ ""+ " "+ " "+ " "+""+""+"I"+"3"+"1000171"+"1000171"+""+""+""+"10"+"false"+""+ " "+ " "+ "";
InputStream is=null;
HttpClient client=new HttpClient();
//原始参数PostMethod method=新的PostMethod("https://my336304.sapbydesign.com/sap/bc/srt/scs/sap/querysupplierin1?sap vhost=my336304。sapbydesign.com网站");
方法.setRequestHeader("主机"https://my336304.sapbydesign.com");
方法.setRequestHeader("内容类型","text/xml;charset=utf-8");方法.setRequestHeader("授权","基本X1RFU1Q6UHA4MzAyMDQ=");方法.setRequestHeader("用户名",物联网培训,"测试");方法.setRequestHeader("Password","*******");
RequestEntity RequestEntity=new StringRequestEntity(soapRequestData);方法.setRequestEntity(请求实体);
尝试{
client.executeMethod方法(方法);
is=方法.GetResponseBodyAstream();
文件=Jsoup.parse文件(为"UTF-8〃,");
系统错误打印(文档);
}catch(异常e){
e.printStackTrace();
}finally{
方法.释放连接();
尝试{
如果(是!=null){
很接近();
}
}catch(IOException e){
e.printStackTrace();
}
}
return result;
}
public static void main(String[]args){//TODO自动生成的方法存根//系统输出打印("HELLOWORLD");
CallBYDQuerysupplier t=new CallBYDQuerysupplier();String result=t.invokeRemoteFuc();系统输出打印(结果);}
}4.结果为xml文件:
,淘客推广