• 欢迎访问搞代码网站,推荐使用最新版火狐浏览器和Chrome浏览器访问本网站!
  • 如果您觉得本站非常有看点,那么赶紧使用Ctrl+D 收藏搞代码吧

org.apache.axis2.AxisFault: Transport error: 411 Error: Leng

mysql 搞代码 4年前 (2022-01-09) 20次浏览 已收录 0个评论

package axiom; import java.util.Date; import org.apache.axiom.om.OMAbstractFactory; import org.apache.axiom.om.OMElement; import org.apache.axiom.om.OMFactory; import org.apache.axiom.om.OMNamespace; import org.apache.axiom.soap.SOAP11Cons

package axiom;

import java.util.Date;

import org.apache.axiom.om.OMAbstractFactory;
import org.apache.axiom.om.OMElement;
import org.apache.axiom.om.OMFactory;
import org.apache.axiom.om.OMNamespace;
import org.apache.axiom.soap.SOAP11Constants;
import org.apache.axis2.AxisFault;
import org.apache.axis2.Constants;
import org.apache.axis2.addressing.EndpointReference;
import org.apache.axis2.client.Options;
import org.apache.axis2.client.ServiceClient;
import org.apache.axis2.transport.http.HTTPConstants;
import org.apache.axis2.transport.http.HttpTransportProperties.ProxyProperties;

public class WeatherAxiomClient {

private static EndpointReference targetEPR =
new EndpointReference(
http://www.webxml.com.cn/WebServices/WeatherWebService.asmx”);

private static OMFactory fac = OMAbstractFactory.getOMFactory();

public static void main(String args[]) throws AxisFault{
Date start=new Date();
System.out.println(“start:”+start);
ServiceClient sender = new ServiceClient();
sender.setOptions(buildOptions());
OMElement result = sender.sendReceive(buildParam());
System.out.println(result);
Date end=new Date();
System.out.println(“end:”+end);
System.out.println(“between:”+(end.getTime()-start.getTime()));
}
public static OMElement buildParam() {
OMNamespace omNs = fac.createOMNamespace(“http://WebXml.com.cn/”, “tns”);
OMElement data = fac.createOMElement(“getSupportCity”, omNs);
OMElement inner = fac.createOMElement(“byProvinceName”, omNs);
inner.setText(“All”);
data.addChild(inner);
return data;

}

public static Options buildOptions(){
Options options = new Options();
options.setSoapVersionURI(SOAP11Constants.SOAP_ENVELOPE_NAMESPACE_URI);
options.setAction(“http://WebXml.com.cn/getSupportCity”);
options.setTo(targetEPR);
options.setTransportInProtocol(Constants.TRANSPORT_HTTP);
// options.setProperty(HTTPConstants.CHUNKED, “false”);//设置不受限制.
options.setProperty(HTTPConstants.PROXY, buildProxy本文来源gaodai#ma#com搞@@代~&码网());
return options;

}
public static ProxyProperties buildProxy(){
ProxyProperties proxyProperties=new ProxyProperties();
proxyProperties.setProxyName(“172.19.18.22”);
proxyProperties.setProxyPort(8080);
return proxyProperties;
}

}
点评:这里有一点要注意的是,当采用axiom进行服务端webservice调用时,http会受限制,所以以上注释的地方必需加上,就可以访问了


搞代码网(gaodaima.com)提供的所有资源部分来自互联网,如果有侵犯您的版权或其他权益,请说明详细缘由并提供版权或权益证明然后发送到邮箱[email protected],我们会在看到邮件的第一时间内为您处理,或直接联系QQ:872152909。本网站采用BY-NC-SA协议进行授权
转载请注明原文链接:org.apache.axis2.AxisFault: Transport error: 411 Error: Leng

喜欢 (0)
[搞代码]
分享 (0)
发表我的评论
取消评论

表情 贴图 加粗 删除线 居中 斜体 签到

Hi,您需要填写昵称和邮箱!

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址