使用Eclipse自动生成Soap Client的代码
在项目按右键,选择New -> Other ->Web Services -> Web Service Client,进入向导。
加入自有代码,例如加入Envelope Header
在xxxxStub.java文件相应的方法中加入:
public com.example.api.ApiStatus.EchoResponse echo(com.example.api.ApiStatus.Echo echo) throws java.rmi.RemoteException {
if (super.cachedEndpoint == null) {
throw new org.apache.axis.NoEndPointException();
org.apache.axis.client.Call _call = createCall();
_call.setOperation(_operations[0]);
_call.setUseSOAPAction(true);
_call.setSOAPActionURI("");
_call.setEncodingStyle(null);
_call.setProperty(org.apache.axis.client.Call.SEND_TYPE_ATTR, Boolean.FALSE);
_call.setProperty(org.apache.axis.AxisEngine.PROP_DOMULTIREFS, Boolean.FALSE);
_call.setSOAPVersion(org.apache.axis.soap.SOAPConstants.SOAP11_CONSTANTS);
_call.setOperationName(new javax.xml.namespace.QName("", "echo"));
setRequestHeaders(_call);
setAttachments(_call);
//这里是加入的Header的内容
SoapUtils.addAuthSoapHeader(_call);
try {
。。。。。。
public class SoapUtils {
private static final Logger log = LogManager.getLogger();
private static SOAPFactory soapFactory;
static{
try {
soapFactory = SOAPFactory.newInstance();
} catch (SOAPException e) {
log.fatal("[FATAL] create SOAP Factory error : {}",e.toString());
//参考http://blog.csdn.net/oscar999/article/details/40340819
private static SOAPHeaderElement createDcpSoapHeader(String userName, String password){
try {
String AUTH_PREFIX = "wsse";
String AUTH_NS = "http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd";
SOAPElement wsSecHeaderElm = soapFactory.createElement("Security", AUTH_PREFIX, AUTH_NS);
SOAPElement userNameTokenElm = soapFactory.createElement("UsernameToken", AUTH_PREFIX, AUTH_NS);
SOAPElement userNameElm = soapFactory.createElement("Username", AUTH_PREFIX, AUTH_NS);
SOAPElement passwdElm = soapFactory.createElement("Password", AUTH_PREFIX, AUTH_NS);
userNameElm.addTextNode(userName);
passwdElm.addTextNode(password);
userNameTokenElm.addChildElement(userNameElm);
userNameTokenElm.addChildElement(passwdElm);
wsSecHeaderElm.addChildElement(userNameTokenElm);
SOAPHeaderElement soapHeaderElement = new SOAPHeaderElement(wsSecHeaderElm);
soapHeaderElement.setMustUnderstand(true);
return soapHeaderElement;
} catch (Exception e) {
return null;
public static void addAuthSoapHeader(org.apache.axis.client.Call call,String userName, String password){
SOAPHeaderElement header = createDcpSoapHeader(userName,password);
if(header != null)
call.addHeader(header);
更好的方式还可以参考 Web Service SOAP Client 设置 SOAP Header,那里给出更通用的解决方式,而这里需要对每个接口都进行设置。主要是了解一下soap client的代码。
网络出现问题,多次重发的实现
利用Java的Function类,在SoapUtils实现通用的多次重发方法。
public class SoapUtils {
private static final Logger log = LogManager.getLogger();
......
//在log上显示错误,并判断是否因为网络连接问题而需要重复
public static boolean showAndCheckRetryEAxisFault(Exception e){
if( e instanceof ConnectException)
return true;
if( e instanceof AxisFault){
AxisFault fault = (AxisFault)e;
if(fault.getFaultString().startsWith("java.net.ConnectException"))
return true;
log.error( fault.dumpToString());
return false;
return false;
//在log上显示错误
public static void showAxisFault(Exception e){
if( e instanceof AxisFault){
AxisFault fault = (AxisFault)e;
log.error( fault.dumpToString());
// 根据重复后退的retriesDelay参数,在网络出现故障时,进行重复。其中SoapUtils.ThrowingFunction<T, R> func就是soap proxy中的具体某个方法。这个func因为抛出异常,不能直接使用Function<T,R>,需要通过ThrowingFunction<T,R> extends Function<T,R>来实现。
public static <T, R> R funcApplyWithThrow(SoapUtils.ThrowingFunction<T, R> func,T param, Long ... retriesDelay) throws AxisFault,Exception{
if(retriesDelay != null){
for(int i = 0 ; i< retriesDelay.length ; i ++){
try {
return func.applyThrows(param);
} catch (Exception e) {
if(!SoapUtils.showAndCheckRetryEAxisFault(e))
throw e;
log.debug("Try to fix {}, resend({}) after {}ms", e.toString(), i+1, retriesDelay[i]);
NormalUtils.sleep(retriesDelay[i]);
return func.applyThrows(param);
}catch(Exception e){
SoapUtils.showAxisFault(e);
throw e;
//参考slieb.org/blog/throwable-interfaces/
@FunctionalInterface
public static interface ThrowingFunction<T,R> extends Function<T,R> {
@Override
default R apply(T t){
return applyThrows(t);
}catch (RemoteException e){
throw new RuntimeException(e);
R applyThrows(T t) throws RemoteException;
具体某个重发的实现:
private final MySoapProxy proxy = new MySoapProxy(url);
@Override
public QueryResponse query(Long ...retriesDelay) throws AxisFault,Exception{
QueryParam param = new QueryParam();
return SoapUtils.funcApplyWithThrow(proxy::query, param, retriesDelay);
相关链接:我的Professional Java for Web Applications相关文章
使用Eclipse自动生成Soap Client的代码在项目按右键,选择New -&gt; Other -&gt;Web Services -&gt; Web Service Client,进入向导。加入自有代码,例如加入Envelope Header在xxxxStub.java文件相应的方法中加入:public com.example.api.ApiStatus.EchoResponse ech...
SOAP有大体两种模式WSDL模式和non-WSDL模式。WSDL模式访问的url中带有?wsdl,SoapClient在实例化的时候需要传入第一个参数。
无论是何种模式,方法的参数结构都需要根据服务端的要求填写。最好是服务端提供可正常请求的报文【即请求xml文件】。
还有一种比较直接的访问方式是用__doRequest(),直接用自己生成的报文请求,这是用来检验上述两种模式形成的
修改php.ini
得添加extension=php_soap.dll (加载soap 内置包)
修改soap.wsdl_cache_enabled=1 改为soap.wsdl_cache_enabled=0 这个是soap的缓存,测试的时候最好改为0,上线稳定了改为1
soap有两种模式一种是wsdl,一种是no-wsdl
二,熟悉几个函
如果要连接web service,目前比较通用的是使用soap的方式连接,对我们影响最直接的就是要学会使用soapclient,下面就对soapclient的使用作一些总结,希望能有所帮助。
一般来说有两种常用的连接方法,一种是使用wsdl文件,另一种是直接连接远程服务。
对于第一种方法,wsdl文件可以放在本地,也可以是通过远程引用,具体方法如下:
$soap = new So
在接口对接当中,WebService接口占有着很大份额,而我们为了使用这些接口,不得不引入类似Axis等库来实现接口请求。
现在有了Hutool,就可以在无任何依赖的情况下,实现简便的WebService请求。
使用SoapUI解析WSDL地址,找到WebService方法和参数。
我们得到的XML模板为:
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:web="h
一,什么是soap,什么是wsdl,为什么要用他们
SOAP是基于XML和HTTP通信协议,xml各种平台,各种语言都支持的一个种语言。http呢它得到了所有的因特网浏览器及服务器的支持。
WSDL 指网络服务描述语言 (Web Services Description Language),是一种使用 XML 编写的文档。这种文档可描述某个 Web service。它可规定服务的位置,
$ soapClient = new \ Camcima \ Soap \ Client ( $ wsdl , $ options , $ sslVerifyPeer );
sslVerifyPeer的默认值为true ,这意味着将验证SSL证书。 如果WSDL文件托管在具有无效SSL证书或自签名证书的服务器上,请将sslVerifyPeer设置为false 。
cURL选项
该包装器使用cURL发出HTTP请求。 可以使用cURL选项来自定义SOAP请求。
$ curlOptions = array (
CURLOPT_CRLF => true ,
CURLOPT_SSL_VERIFYPEER
这里写自定义目录标题前言http走私攻击本题需要重点关注的析构函数SoapCLient+CRLF代码审计参考文章
如果在代码审计中有反序列化点,但在代码中找不到pop链,可以利用php内置类来进行反序列化
http走私攻击
关于http走私攻击和实战大家可以参考下这篇文章:https://xz.aliyun.com/t/6654#toc-3
本题需要重点关注的析构函数
__call 在对象中调用一个不可访问方法时调用
在这道题中$vip->getFlag();因为调用了类中没有的方法所以会导致_
很高兴为您提供回复。
spring mvc 是一种基于 Java 的 web 框架,它可以帮助开发者快速构建 web 应用程序。在学习 spring mvc 的过程中,第一步就是编写一个简单的 helloworld 程序。
在这个 helloworld 程序中,我们需要创建一个控制器类,这个类需要使用 @Controller 注解来标识。然后,我们需要在这个类中编写一个处理请求的方法,这个方法需要使用 @RequestMapping 注解来标识。
在这个方法中,我们可以编写一些简单的逻辑,比如输出一段文本或者返回一个视图。最后,我们需要在配置文件中配置这个控制器类,以便让 spring mvc 能够找到它并将请求转发给它。
总的来说,学习 spring mvc 的 helloworld 程序是一个很好的入门练习,它可以帮助我们了解 spring mvc 的基本原理和使用方法。