SOAP基于 XML 的简易协议

1、java

springboot 接口

 @WebMethod
 public String test(@WebParam(name = "str")String str) {
    
    
      // try {
    
    
      //     Thread.sleep(1000 * 30);
      // } catch (InterruptedException e) {
    
    
      //     // TODO Auto-generated catch block
      //     e.printStackTrace();
      // }
      System.out.println("被调用啦");
      System.out.println(str);
      if(str.equals("1"))
      return "这是1。";
      else return "这不是1。";
  }

发送 和 接收

Content-Type text/xml;charset=utf-8
<!-- http://soap.api.sobg.gzmpc.com/  自己的地址
	test 方法名
	str参数名
 -->
<?xml version='1.0' encoding='UTF-8'?>
<S:Envelope xmlns:S="http://schemas.xmlsoap.org/soap/envelope/" 
 xmlns:ns4="http://soap.api.sobg.gzmpc.com/" 
 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
  xmlns:xsd="http://www.w3.org/1999/XMLSchema">
    <S:Body>
        <ns4:test>
            <str xsi:type="xsd:string">3</str>
        </ns4:test>
    </S:Body>
</S:Envelope>


<?xml version='1.0' encoding='UTF-8'?>
<S:Envelope xmlns:S="http://schemas.xmlsoap.org/soap/envelope/">
    <S:Body>
        <ns2:testResponse xmlns:ns2="http://soap.api.sobg.gzmpc.com/">
            <return>这不是1。</return>
        </ns2:testResponse>
    </S:Body>
</S:Envelope>

猜你喜欢

转载自blog.csdn.net/weixin_41544662/article/details/130506402
今日推荐