乡下人产国偷v产偷v自拍,国产午夜片在线观看,婷婷成人亚洲综合国产麻豆,久久综合给合久久狠狠狠9

  • <output id="e9wm2"></output>
    <s id="e9wm2"><nobr id="e9wm2"><ins id="e9wm2"></ins></nobr></s>

    • 分享

      spring boot 整合webservice客戶端 根據(jù)wsdl文件自動生成客戶端代碼

       印度阿三17 2019-03-27

      添加依賴
      客戶端,同樣的需要先添加依賴:

      <dependency>
          <groupId>org.springframework.boot</groupId>
         <artifactId>spring-boot-starter-ws</artifactId>
      </dependency>
      <dependency>
         <groupId>wsdl4j</groupId>
        <artifactId>wsdl4j</artifactId>
      </dependency>
      

      獲取wsdl文件
      服務(wù)端由一個xsd文件開始,客戶端則是由一個wsdl文件開始。
      獲取wsdl文件也十分簡單,用瀏覽器訪問web service地址,然后另存為即可。當(dāng)然也可以直接用url地址來生成代碼,只不過我習(xí)慣本地另存為后再生成。
      完整的wsdl文件內(nèi)容如下:

      <wsdl:definitions 
         xmlns:wsdl="http://schemas./wsdl/" 
          xmlns:sch="http://www./ws" 
        xmlns:soap="http://schemas./wsdl/soap/" 
          xmlns:tns="http://www./ws" targetNamespace="http://www./ws">
          <wsdl:types>
             <xs:schema 
                  xmlns:xs="http://www./2001/XMLSchema" elementFormDefault="qualified" targetNamespace="http://www./ws">
                  <xs:element name="getCountryRequest">
                     <xs:complexType>
                        <xs:sequence>
                             <xs:element name="name" type="xs:string"/>
                        </xs:sequence>
                     </xs:complexType>
                 </xs:element>
               <xs:element name="getCountryResponse">
                     <xs:complexType>
                        <xs:sequence>
                            <xs:element name="country" type="tns:country"/>
                       </xs:sequence>
                    </xs:complexType>
                 </xs:element>
                 <xs:complexType name="country">
                      <xs:sequence>
                         <xs:element name="name" type="xs:string"/>
                         <xs:element name="population" type="xs:int"/>
                          <xs:element name="capital" type="xs:string"/>
                         <xs:element name="currency" type="tns:currency"/>
                     </xs:sequence>
                 </xs:complexType>
                  <xs:simpleType name="currency">
                     <xs:restriction base="xs:string">
                          <xs:enumeration value="GBP"/>
                         <xs:enumeration value="EUR"/>
                         <xs:enumeration value="PLN"/>
                    </xs:restriction>
                  </xs:simpleType>
             </xs:schema>
          </wsdl:types>
          <wsdl:message name="getCountryResponse">
            <wsdl:part element="tns:getCountryResponse" name="getCountryResponse"></wsdl:part>
         </wsdl:message>
         <wsdl:message name="getCountryRequest">
             <wsdl:part element="tns:getCountryRequest" name="getCountryRequest"></wsdl:part>
          </wsdl:message>
         <wsdl:portType name="CountriesPort">
              <wsdl:operation name="getCountry">
                  <wsdl:input message="tns:getCountryRequest" name="getCountryRequest"></wsdl:input>
      49.            <wsdl:output message="tns:getCountryResponse" name="getCountryResponse"></wsdl:output>
             </wsdl:operation>
        </wsdl:portType>
          <wsdl:binding name="CountriesPortSoap11" type="tns:CountriesPort">
            <soap:binding style="document" transport="http://schemas./soap/http"/>
            <wsdl:operation name="getCountry">
                 <soap:operation soapAction=""/>
                  <wsdl:input name="getCountryRequest">
                     <soap:body use="literal"/>
                </wsdl:input>
                 <wsdl:output name="getCountryResponse">
                     <soap:body use="literal"/>
                </wsdl:output>
             </wsdl:operation>
         </wsdl:binding>
          <wsdl:service name="CountriesPortService">
             <wsdl:port binding="tns:CountriesPortSoap11" name="CountriesPortSoap11">
                 <soap:address/>
            </wsdl:port>
         </wsdl:service>
      </wsdl:definitions>
      

      添加maven的jaxb2插件生成代碼
      跟服務(wù)端根據(jù)xsd來生成代碼類似,客戶端同樣可以根據(jù)wsdl來生成代碼。maven插件依賴:

      <plugin>
          <groupId>org.jvnet.jaxb2.maven2</groupId>
          <artifactId>maven-jaxb2-plugin</artifactId>
         <version>0.12.3</version>
          <executions>
              <execution>
                  <goals>
                     <goal>generate</goal>
                  </goals>
             </execution>
          </executions>
      .    <configuration>
             <schemaLanguage>WSDL</schemaLanguage>
             <generatePackage>com.dexcoder.ws</generatePackage>
              <generateDirectory>${basedir}/src/main/java</generateDirectory>
            <schemas>
                 <schema>
                      <fileset>
                         <!-- Defaults to schemaDirectory. -->
                          <directory>${basedir}/src/main/resources/schemas</directory>
                         <!-- Defaults to schemaIncludes. -->
                         <includes>
                              <include>*.wsdl</include>
                        </includes>
                          <!-- Defaults to schemaIncludes -->
                          <!--<excludes>-->
                       <!--<exclude>*.xs</exclude>-->
                       <!--</excludes>-->
      .                </fileset>
                     <!--<url>http://localhost:8080/ws/countries.wsdl</url>-->
                  </schema>
              </schemas>
          </configuration>
      </plugin>
      

      然后執(zhí)行mvn install 來生成對應(yīng)的文件。
      mvn install 執(zhí)行的步驟:
      第一步:進(jìn)入項(xiàng)目跟目錄
      第二步:在跟目錄的地址欄中輸入cmd回車
      第三步驟:輸入mvn install回車

      來源:http://www./content-4-150001.html

        本站是提供個人知識管理的網(wǎng)絡(luò)存儲空間,所有內(nèi)容均由用戶發(fā)布,不代表本站觀點(diǎn)。請注意甄別內(nèi)容中的聯(lián)系方式、誘導(dǎo)購買等信息,謹(jǐn)防詐騙。如發(fā)現(xiàn)有害或侵權(quán)內(nèi)容,請點(diǎn)擊一鍵舉報。
        轉(zhuǎn)藏 分享 獻(xiàn)花(0

        0條評論

        發(fā)表

        請遵守用戶 評論公約

        類似文章 更多