2024年最全Web Service进阶(一)运行原理_web service 原理(1),前端开发岗位要求

总结

前端资料汇总

开源分享:【大厂前端面试题解析+核心总结学习笔记+真实项目实战+最新讲解视频】

  • 框架原理真的深入某一部分具体的代码和实现方式时,要多注意到细节,不要只能写出一个框架。

  • 算法方面很薄弱的,最好多刷一刷,不然影响你的工资和成功率😯

  • 在投递简历之前,最好通过各种渠道找到公司内部的人,先提前了解业务,也可以帮助后期优秀 offer 的决策。

  • 要勇于说不,对于某些 offer 待遇不满意、业务不喜欢,应该相信自己,不要因为当下没有更好的 offer 而投降,一份工作短则一年长则 N 年,为了幸福生活要慎重选择!!!
    喜欢这篇文章文章的小伙伴们点赞+转发支持,你们的支持是我最大的动力!

/**
* 通过SOAP1.1协议调用Web服务
* 
* text/xml 这是基于soap1.1协议
* 
* @param wsdl WSDL路径
* @param method方法名
* @param namespace命名空间
* @param headerParameters 头参数
* @param bodyParameters   体参数
* @param isBodyParametersNS 体参数是否有命名空间
* @return String
* @throws Exception
*/
public static String invokeBySoap11(String wsdl, String method,
String namespace, Map<String, String> headerParameters,
Map<String, String> bodyParameters, boolean isBodyParametersNS)
throws Exception {
    StringBuffer soapOfResult = null;
    // 去除 ?wsdl,获取方法列表
    int length = wsdl.length();
    wsdl = wsdl.substring(0, length - 5);
    // 以字符串为参数创建URL实例
    URL url = new URL(wsdl);
    // 创建连接
    HttpURLConnection conn = (HttpURLConnection) url.openConnection();
    // 设置请求方式
    conn.setRequestMethod("POST");
    // 如果打算使用 URL连接进行输入,则将 DoInput 标志设置为 true
    conn.setDoInput(true);
    // 如果打算使用 URL连接进行输出,则将 DoInput 标志设置为 true
    conn.setDoOutput(true);
    // 主要是设置HttpURLConnection请求头里面的属性(K-V)
    conn.setRequestProperty("Content-Type", "text/xml;charset=utf-8");
    // 获取输入流(相对于客户端来说,使用的是OutputStream)
    OutputStream out = conn.getOutputStream();
    // 获取soap1.1版本消息
    StringBuilder sb = new StringBuilder();
    sb.append("<soap:Envelope xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" 
    xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\"         xmlns:soap=\"http://schemas.xmlsoap.org/soap/envelope/\" ");
    sb.append("xmlns:ns0=\"" + namespace + "\"");
    sb.append(">");
    // 拼装消息头
    if (headerParameters != null) {
    sb.append("<soap:Header>");
    for (Entry<String, String> headerParameter : headerParameters
    .entrySet()) {
        sb.append("<ns0:");
        sb.append(headerParameter.getKey());
        sb.append(">");
        sb.append(headerParameter.getValue());
        sb.append("</ns0:");
        sb.append(headerParameter.getKey());
        sb.append(">");
    }
    sb.append("</soap:Header>");
}
// 拼装消息体
sb.append("<soap:Body><ns0:");
sb.append(method);
sb.append(">");
// 输入参数
if (bodyParameters != null) {
    for (Entry<String, String> inputParameter : bodyParameters
    .entrySet()) {
        if (isBodyParametersNS) {
            sb.append("<ns0:");
            sb.append(inputParameter.getKey());
            sb.append(">");
            sb.append(inputParameter.getValue());
            sb.append("</ns0:");
            sb.append(inputParameter.getKey());
            sb.append(">");
        } else {
            sb.append("<");
            sb.append(inputParameter.getKey());
            sb.append(">");
            sb.append(inputParameter.getValue());
            sb.append("</");
            sb.append(inputParameter.getKey());
            sb.append(">");
        }
    }
}
sb.append("</ns0:");
sb.append(method);
sb.append("></soap:Body></soap:Envelope>");
//测试用
System.out.println(sb.toString());
//写入SOAP消息(相对于客户端来说,使用的是out.write())
out.write(sb.toString().getBytes());
//获取服务器端的相应
int code = conn.getResponseCode();
if (code == 200) {
    InputStream is = conn.getInputStream();
    byte[] b = new byte[1024];
    int len = 0;
    soapOfResult = new StringBuffer();
    // 从输入流中读取一定数量的字节,并将其存储在缓冲区数组 b 中。以整数形式返回实际读取的字节数
    // 如果因为流位于文件末尾而没有可用的字节,则返回值 -1;
    while ((len = is.read(b)) != -1) {
        // Converts the byte array to a string using the named charset. 
        String s = new String(b, 0, len, "UTF-8");
        soapOfResult.append(s);
    }
}
conn.disconnect();
return soapOfResult == null ? null : soapOfResult.toString();
}

注:在客户端发送SOAP请求消息后便处于阻塞状态。直至服务端返回状态码。

以下为服务端进行响应(SOAP Response Envelope):

<S:Envelope xmlns:S="http://schemas.xmlsoap.org/soap/envelope/">
<S:Body>
<ns2:loginResponse xmlns:ns2="http://ujn.cn/">
  <return>1</return>
</ns2:loginResponse>
  </S:Body>
</S:Envelope>

客户端接收到服务端发来的Json数据后会进行相应的解析操作。如下:

// 将Soap协议进行解析(DOM解析只能用于解析XML文档类型,而SOAP消息就是采用XML数据格式)
Document doc = XmlUtil.string2Doc(result);
Element ele = (Element) doc.getElementsByTagName("return").item(0);
方法中使用到的string2Doc()方法体如下:
public static Document string2Doc(String str) {
    //将XML文档解析成DOM树
    DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
    Document document = null;
    DocumentBuilder build;
    if (str == null || str.equals("")) {
        return null;
    }
try {
    InputStream bais = new ByteArrayInputStream(str.getBytes("UTF-8"));
    build = factory.newDocumentBuilder();
    //Parse the content of the given InputStream as an XML document and return a new DOM Document object. 
    document = build.parse(bais);
} catch (Exception e) {
    e.printStackTrace();
}
    return document;
}
#### 总结一下



面试前要精心做好准备,简历上写的知识点和原理都需要准备好,项目上多想想难点和亮点,这是面试时能和别人不一样的地方。

还有就是表现出自己的谦虚好学,以及对于未来持续进阶的规划,企业招人更偏爱稳定的人。

**[开源分享:【大厂前端面试题解析+核心总结学习笔记+真实项目实战+最新讲解视频】](https://bbs.csdn.net/topics/618166371)**

万事开头难,但是程序员这一条路坚持几年后发展空间还是非常大的,一切重在坚持。



为了帮助大家更好更高效的准备面试,特别整理了《前端工程师面试手册》电子稿文件。

![](https://img-blog.csdnimg.cn/img_convert/621960a57eb42479e02d6d64c0c81891.png)



![](https://img-blog.csdnimg.cn/img_convert/5230c48fd0fcb265f3401a21603bda2b.png)



**前端面试题汇总**



![](https://img-blog.csdnimg.cn/img_convert/42728594459506983a38ca2b86545fc6.png)

**JavaScript**



![](https://img-blog.csdnimg.cn/img_convert/7796de226b373d068d8f5bef31e668ce.png)



**性能**

![](https://img-blog.csdnimg.cn/img_convert/d7f6750332c78eb27cc606540cdce3b4.png)



**linux**



![](https://img-blog.csdnimg.cn/img_convert/ed368cc25284edda453a4c6cb49916ef.png)



**前端资料汇总**

![](https://img-blog.csdnimg.cn/img_convert/6e0ba223f65e063db5b1b4b6aa26129a.png)

前端工程师岗位缺口一直很大,符合岗位要求的人越来越少,所以学习前端的小伙伴要注意了,一定要把技能学到扎实,做有含金量的项目,这样在找工作的时候无论遇到什么情况,问题都不会大。



  • 3
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值