日日操夜夜添-日日操影院-日日草夜夜操-日日干干-精品一区二区三区波多野结衣-精品一区二区三区高清免费不卡

公告:魔扣目錄網(wǎng)為廣大站長(zhǎng)提供免費(fèi)收錄網(wǎng)站服務(wù),提交前請(qǐng)做好本站友鏈:【 網(wǎng)站目錄:http://www.ylptlb.cn 】, 免友鏈快審服務(wù)(50元/站),

點(diǎn)擊這里在線咨詢客服
新站提交
  • 網(wǎng)站:51998
  • 待審:31
  • 小程序:12
  • 文章:1030137
  • 會(huì)員:747

本文介紹了如何使用動(dòng)態(tài)SOAP:使用Spring-WS發(fā)布地址位置的處理方法,對(duì)大家解決問題具有一定的參考價(jià)值,需要的朋友們下面隨著小編來一起學(xué)習(xí)吧!

問題描述

我希望根據(jù)保存它們的環(huán)境來更改<soap:address location="..."/>。例如:

開發(fā):<soap:address location="https://development.xxx.yyy.zz/abc/ws/"/>

測(cè)試:<soap:address location="https://testing.xxx.yyy.zz/abc/ws/"/>

生產(chǎn):<soap:address location="https://production.xxx.yyy.zz/abc/ws/"/>

wsdl

如果要使用推薦答案基本文件,并且只根據(jù)環(huán)境更改SOAP地址位置屬性,請(qǐng)使用以下類:

import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.transform.Source;
import javax.xml.transform.dom.DOMSource;
import javax.xml.transform.sax.SAXSource;
import javax.xml.xpath.XPath;
import javax.xml.xpath.XPathConstants;
import javax.xml.xpath.XPathFactory;

import org.springframework.beans.factory.InitializingBean;
import org.springframework.core.io.Resource;
import org.springframework.util.StringUtils;
import org.springframework.ws.wsdl.wsdl11.SimpleWsdl11Definition;
import org.springframework.ws.wsdl.wsdl11.Wsdl11Definition;
import org.w3c.dom.Document;
import org.w3c.dom.Node;

public class DynamicUrlWsdlDefinition implements Wsdl11Definition, InitializingBean {

  private static final String SOAP_ADDRESS_LOCATION_XPATH_EXPRESSION = "/definitions/service/port/address/@location";

  private static final String SOAP_ADDRESS_LOCATION_URI_PART_1 = "https://";

  private static final String SOAP_ADDRESS_LOCATION_URI_PART_3 = ".xxx.yyy.zz/abc/ws/";

  private String wsEnvironment;

  private SimpleWsdl11Definition delegate;

  public DynamicUrlWsdlDefinition() {
    this.setDelegate(new SimpleWsdl11Definition());
  }

  @Override
  public Source getSource() {
    try {
      final DocumentBuilderFactory documentBuilderFactory = DocumentBuilderFactory.newInstance();
      final DocumentBuilder documentBuilder = documentBuilderFactory.newDocumentBuilder();
      final Document document = documentBuilder.parse(((SAXSource) this.getDelegate().getSource()).getInputSource());

      final XPath xPath = XPathFactory.newInstance().newXPath();
      final Node locationAttributeNode = (Node) xPath.compile(SOAP_ADDRESS_LOCATION_XPATH_EXPRESSION)
          .evaluate(document, XPathConstants.NODE);
      locationAttributeNode.setTextContent(SOAP_ADDRESS_LOCATION_URI_PART_1 + this.getWsEnvironment() + SOAP_ADDRESS_LOCATION_URI_PART_3);

      return new DOMSource(document);
    } catch (Exception e) {
      return this.getDelegate().getSource();
    }
  }

  private String getWsEnvironment() {
    if (!StringUtils.hasText(wsEnvironment) || "${ws.environment}".equals(wsEnvironment)) {
      this.setWsEnvironment("NO_DEFINED");
    }
    return wsEnvironment;
  }

  @Override
  public void afterPropertiesSet() throws Exception {
    this.getDelegate().afterPropertiesSet();
  }

  public void setWsdl(final Resource wsdlResource) {
    this.getDelegate().setWsdl(wsdlResource);
  }

  private SimpleWsdl11Definition getDelegate() {
    return delegate;
  }

  private void setDelegate(final SimpleWsdl11Definition delegate) {
    this.delegate = delegate;
  }

  public void setWsEnvironment(final String wsEnvironment) {
    this.wsEnvironment = wsEnvironment;
  }

}

并聲明此Spring Bean:

<bean id="pingoServiceWsdl" class="DynamicUrlWsdlDefinition">
    <property name="wsdl" value="classpath:/pingoService.wsdl"/>
    <property name="wsEnvironment" value="${ws.environment}"/>
</bean>

這篇關(guān)于如何使用動(dòng)態(tài)SOAP:使用Spring-WS發(fā)布地址位置的文章就介紹到這了,希望我們推薦的答案對(duì)大家有所幫助,

分享到:
標(biāo)簽:Spring WS 位置 動(dòng)態(tài) 發(fā)布 地址 如何使用
用戶無頭像

網(wǎng)友整理

注冊(cè)時(shí)間:

網(wǎng)站:5 個(gè)   小程序:0 個(gè)  文章:12 篇

  • 51998

    網(wǎng)站

  • 12

    小程序

  • 1030137

    文章

  • 747

    會(huì)員

趕快注冊(cè)賬號(hào),推廣您的網(wǎng)站吧!
最新入駐小程序

數(shù)獨(dú)大挑戰(zhàn)2018-06-03

數(shù)獨(dú)一種數(shù)學(xué)游戲,玩家需要根據(jù)9

答題星2018-06-03

您可以通過答題星輕松地創(chuàng)建試卷

全階人生考試2018-06-03

各種考試題,題庫,初中,高中,大學(xué)四六

運(yùn)動(dòng)步數(shù)有氧達(dá)人2018-06-03

記錄運(yùn)動(dòng)步數(shù),積累氧氣值。還可偷

每日養(yǎng)生app2018-06-03

每日養(yǎng)生,天天健康

體育訓(xùn)練成績(jī)?cè)u(píng)定2018-06-03

通用課目體育訓(xùn)練成績(jī)?cè)u(píng)定