2013-10-21 2 views
15

자바에서 SOAP 라이브러리를 사용한 적이 없으므로이 질문의 newby-ness에 대해 사과드립니다.주어진 WSDL 파일에서 java에서 SOAP 클라이언트 생성하기

Tivoli Endpoint Manager의 SOAP API를 활용하려고합니다. 제공된 wsimport.exe (jdk에서 제공)를 사용하여 제공된 WSDL 파일에서 필요한 클래스를 생성했습니다.

이제 정보를 xml 형식으로 패키징한다고 가정하는 많은 수업이 제공되지만, 나는 그것들과 어떻게 해야할지 잘 모릅니다. 제공된 설명서를 읽었으나 기껏해야 모호합니다.

wsimport에 의해 생성 된 클래스

은 다음과 같습니다

classes generated by wsimport

문서에 따르면, 다음과 같은 펄 코드는 Tivoli의 API

use SOAP::Lite; 
#arguments: [hostname] [username] [password] [relevance expression] 
#hostname only, e.g. ’example.com’ rather than ’http://example.com/webreports’ 
my $host = $ARGV[0]; 
my $username = SOAP::Data->name(’username’ => $ARGV[1]); 
my $password = SOAP::Data->name(’password’ => $ARGV[2]); 
my $expr = SOAP::Data->name(’relevanceExpr’ => $ARGV[3]); 
my $service = SOAP::Lite -> uri(’http://’ . $host . ’/webreports?wsdl’) 
-> proxy($host); 
my $result = $service -> GetRelevanceResult($expr, $username, $password); 
if($result->fault) { 
    print "faultcode: " . $result->faultcode . "\n"; 
    print "faultstring: " . $result->faultstring . "\n"; 
} 
else { 
    foreach my $answer ($result->valueof("//GetRelevanceResultResponse/a")) { 
      print $answer . "\n"; 
    } 
} 

질문 쿼리 작동 다음은 무엇입니까 Java에서 동등한 SOAP 클라이언트 라이브러리? (내가 봤 거든 그 무거운 15mb +)

위의 펄에 해당하는 자바 스텁 코드는 어떻게 쓸 수 있습니까? 여기에 편집 한

내가이 (가) WebReportsService.java 클래스를 찾을 생각 스텁 코드 입니다

package connect.tivoli; 

import java.net.MalformedURLException; 
import java.net.URL; 
import javax.xml.namespace.QName; 
import javax.xml.ws.Service; 
import javax.xml.ws.WebEndpoint; 
import javax.xml.ws.WebServiceClient; 
import javax.xml.ws.WebServiceException; 
import javax.xml.ws.WebServiceFeature; 


/** 
* This class was generated by the JAX-WS RI. 
* JAX-WS RI 2.2.4-b01 
* Generated source version: 2.2 
* 
*/ 
@WebServiceClient(name = "WebReportsService", targetNamespace = "http://schemas.bigfix.com/Relevance", wsdlLocation = "http://temwebreports/webreports?wsdl") 
public class WebReportsService 
    extends Service 
{ 

    private final static URL WEBREPORTSSERVICE_WSDL_LOCATION; 
    private final static WebServiceException WEBREPORTSSERVICE_EXCEPTION; 
    private final static QName WEBREPORTSSERVICE_QNAME = new QName("http://schemas.bigfix.com/Relevance", "WebReportsService"); 

    static { 
     URL url = null; 
     WebServiceException e = null; 
     try { 
      url = new URL("http://temwebreports/webreports?wsdl"); 
     } catch (MalformedURLException ex) { 
      e = new WebServiceException(ex); 
     } 
     WEBREPORTSSERVICE_WSDL_LOCATION = url; 
     WEBREPORTSSERVICE_EXCEPTION = e; 
    } 

    public WebReportsService() { 
     super(__getWsdlLocation(), WEBREPORTSSERVICE_QNAME); 
    } 

    public WebReportsService(WebServiceFeature... features) { 
     super(__getWsdlLocation(), WEBREPORTSSERVICE_QNAME, features); 
    } 

    public WebReportsService(URL wsdlLocation) { 
     super(wsdlLocation, WEBREPORTSSERVICE_QNAME); 
    } 

    public WebReportsService(URL wsdlLocation, WebServiceFeature... features) { 
     super(wsdlLocation, WEBREPORTSSERVICE_QNAME, features); 
    } 

    public WebReportsService(URL wsdlLocation, QName serviceName) { 
     super(wsdlLocation, serviceName); 
    } 

    public WebReportsService(URL wsdlLocation, QName serviceName, WebServiceFeature... features) { 
     super(wsdlLocation, serviceName, features); 
    } 

    /** 
    * 
    * @return 
    *  returns RelevancePortType 
    */ 
    @WebEndpoint(name = "RelevancePort") 
    public RelevancePortType getRelevancePort() { 
     return super.getPort(new QName("http://schemas.bigfix.com/Relevance", "RelevancePort"), RelevancePortType.class); 
    } 

    /** 
    * 
    * @param features 
    *  A list of {@link javax.xml.ws.WebServiceFeature} to configure on the proxy. Supported features not in the <code>features</code> parameter will have their default values. 
    * @return 
    *  returns RelevancePortType 
    */ 
    @WebEndpoint(name = "RelevancePort") 
    public RelevancePortType getRelevancePort(WebServiceFeature... features) { 
     return super.getPort(new QName("http://schemas.bigfix.com/Relevance", "RelevancePort"), RelevancePortType.class, features); 
    } 

    /** 
    * 
    * @return 
    *  returns UserManagementPortType 
    */ 
    @WebEndpoint(name = "UserManagementPort") 
    public UserManagementPortType getUserManagementPort() { 
     return super.getPort(new QName("http://schemas.bigfix.com/Relevance", "UserManagementPort"), UserManagementPortType.class); 
    } 

    /** 
    * 
    * @param features 
    *  A list of {@link javax.xml.ws.WebServiceFeature} to configure on the proxy. Supported features not in the <code>features</code> parameter will have their default values. 
    * @return 
    *  returns UserManagementPortType 
    */ 
    @WebEndpoint(name = "UserManagementPort") 
    public UserManagementPortType getUserManagementPort(WebServiceFeature... features) { 
     return super.getPort(new QName("http://schemas.bigfix.com/Relevance", "UserManagementPort"), UserManagementPortType.class, features); 
    } 

    /** 
    * 
    * @return 
    *  returns DashboardVariablePortType 
    */ 
    @WebEndpoint(name = "DashboardVariablePort") 
    public DashboardVariablePortType getDashboardVariablePort() { 
     return super.getPort(new QName("http://schemas.bigfix.com/Relevance", "DashboardVariablePort"), DashboardVariablePortType.class); 
    } 

    /** 
    * 
    * @param features 
    *  A list of {@link javax.xml.ws.WebServiceFeature} to configure on the proxy. Supported features not in the <code>features</code> parameter will have their default values. 
    * @return 
    *  returns DashboardVariablePortType 
    */ 
    @WebEndpoint(name = "DashboardVariablePort") 
    public DashboardVariablePortType getDashboardVariablePort(WebServiceFeature... features) { 
     return super.getPort(new QName("http://schemas.bigfix.com/Relevance", "DashboardVariablePort"), DashboardVariablePortType.class, features); 
    } 

    private static URL __getWsdlLocation() { 
     if (WEBREPORTSSERVICE_EXCEPTION!= null) { 
      throw WEBREPORTSSERVICE_EXCEPTION; 
     } 
     return WEBREPORTSSERVICE_WSDL_LOCATION; 
    } 

} 

솔루션 :

이 나는 ​​것보다 훨씬 간단했다 WSDL 생성이 모든 작업을 수행했다고 생각했습니다. 생성 된 클래스를 사용하는 방법은 다음과 같습니다.

package connect.tivoli;

public class testMain { 

    public static void main(String[] args) { 
     String relevanceQuery ="names of bes computers "; 
     WebReportsService wr = new WebReportsService(); 
     RelevancePortType client; 
     client = wr.getPort(RelevancePortType.class); 
     System.out.println(client.getRelevanceResult(relevanceQuery, "ad\\username", "password")); 
    } 
+1

() 메소드, 다음 (예를 들어, 엔드 포인트) 구현 객체는 당신이 할 수 호출하는 것입니다 모든 웹 서비스 엔드 포인트 메소드. ObjectFactory를 사용하여 필요한 객체를 생성하십시오. 인기있는 클라이언트 라이브러리는 JAX-WS (JRE6 +에 포함) 또는 CXF (Apache에서 제공)입니다. –

+0

Java에서 경량 SOAP 클라이언트에 대해 듣고 싶습니다. Apache CXF는 우리가 사용하는 것으로, 전체 bloatware입니다. – dnault

+1

를 보셨습니까? – deepakborania

답변

20

cxf-codegen-plugin은 WSDL에서 자바 클래스를 자동으로 생성하는 maven 플러그인입니다. 또한 생성 된 코드를 사용하는 방법을 보려면 스텁 클라이언트를 만듭니다.

이 예제에서는 here에있는 wsdl을 다운로드하여 stockquote.wsdl로 저장했습니다.

$ 트리

. 
|-- cxf-wsdl2java-example.iml 
|-- pom.xml 
`-- src 
    |-- main 
    | |-- java 
    | | `-- com 
    | |  `-- stackoverflow 
    | |   `-- App.java 
    | `-- resources 
    |  `-- stockquote.wsdl 
    `-- test 
     `-- java 
      `-- com 
       `-- stackoverflow 
        `-- AppTest.java 

10 directories, 5 files 

$ 고양이의 pom.xml

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
     xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> 
    <modelVersion>4.0.0</modelVersion> 

    <groupId>com.stackoverflow</groupId> 
    <artifactId>cxf-wsdl2java-example</artifactId> 
    <version>1.0</version> 
    <packaging>jar</packaging> 

    <name>cxf-wsdl2java-example</name> 
    <url>http://maven.apache.org</url> 

    <properties> 
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> 
    </properties> 

    <dependencies> 
    <dependency> 
     <groupId>junit</groupId> 
     <artifactId>junit</artifactId> 
     <version>4.11</version> 
     <scope>test</scope> 
    </dependency> 
    </dependencies> 

    <build> 
    <plugins> 
     <plugin> 
     <groupId>org.apache.cxf</groupId> 
     <artifactId>cxf-codegen-plugin</artifactId> 
     <version>2.7.7</version> 
     <executions> 
      <execution> 
      <id>generate-sources</id> 
      <phase>generate-sources</phase> 
      <configuration> 
       <sourceRoot>${project.build.directory}/generated/cxf</sourceRoot> 
       <wsdlOptions> 
       <wsdlOption> 
        <wsdl>${basedir}/src/main/resources/stockquote.wsdl</wsdl> 
        <extraargs> 
        <extraarg>-impl</extraarg> 
        <extraarg>-verbose</extraarg> 
        </extraargs> 
       </wsdlOption> 
       </wsdlOptions> 
      </configuration> 
      <goals> 
       <goal>wsdl2java</goal> 
      </goals> 
      </execution> 
     </executions> 
     </plugin> 
    </plugins> 
    </build> 

</project> 

$ MVN 생성 - 소스

[INFO] Scanning for projects... 
[INFO]                   
[INFO] ------------------------------------------------------------------------ 
[INFO] Building cxf-wsdl2java-example 1.0 
[INFO] ------------------------------------------------------------------------ 
[INFO] 
[INFO] --- cxf-codegen-plugin:2.7.7:wsdl2java (generate-sources) @ cxf-wsdl2java-example --- 
Loading FrontEnd jaxws ... 
Loading DataBinding jaxb ... 
... 
[INFO] ------------------------------------------------------------------------ 
[INFO] BUILD SUCCESS 
[INFO] ------------------------------------------------------------------------ 
[INFO] Total time: 2.462s 
[INFO] Finished at: Mon Oct 21 14:44:54 MDT 2013 
[INFO] Final Memory: 11M/211M 
[INFO] ------------------------------------------------------------------------ 

$ 나무.

. 
|-- cxf-wsdl2java-example.iml 
|-- pom.xml 
|-- src 
| |-- main 
| | |-- java 
| | | `-- com 
| | |  `-- stackoverflow 
| | |   `-- App.java 
| | `-- resources 
| |  `-- stockquote.wsdl 
| `-- test 
|  `-- java 
|   `-- com 
|    `-- stackoverflow 
|     `-- AppTest.java 
`-- target 
    |-- classes 
    |-- cxf-codegen-plugin-markers 
    `-- generated 
     `-- cxf 
      `-- net 
       `-- webservicex 
        |-- GetQuote.java 
        |-- GetQuoteResponse.java 
        |-- ObjectFactory.java 
        |-- package-info.java 
        |-- StockQuoteHttpGetImpl.java 
        |-- StockQuoteHttpGet.java 
        |-- StockQuoteHttpPostImpl.java 
        |-- StockQuoteHttpPost.java 
        |-- StockQuote.java 
        |-- StockQuoteSoapImpl1.java 
        |-- StockQuoteSoapImpl.java 
        `-- StockQuoteSoap.java 

17 directories, 17 files 

$ cat target/generated/cxf/net/webservicex/StockQuote.자바

package net.webservicex; 

import java.net.MalformedURLException; 
import java.net.URL; 
import javax.xml.namespace.QName; 
import javax.xml.ws.WebEndpoint; 
import javax.xml.ws.WebServiceClient; 
import javax.xml.ws.WebServiceFeature; 
import javax.xml.ws.Service; 

/** 
* This class was generated by Apache CXF 2.7.7 
* 2013-10-21T14:44:54.749-06:00 
* Generated source version: 2.7.7 
* 
*/ 
@WebServiceClient(name = "StockQuote", 
        wsdlLocation = "file:/home/axiopisty/projects/cxf-wsdl2java-example/src/main/resources/stockquote.wsdl", 
        targetNamespace = "http://www.webserviceX.NET/") 
public class StockQuote extends Service { 

    public final static URL WSDL_LOCATION; 

    public final static QName SERVICE = new QName("http://www.webserviceX.NET/", "StockQuote"); 
    public final static QName StockQuoteHttpPost = new QName("http://www.webserviceX.NET/", "StockQuoteHttpPost"); 
    public final static QName StockQuoteSoap = new QName("http://www.webserviceX.NET/", "StockQuoteSoap"); 
    public final static QName StockQuoteSoap12 = new QName("http://www.webserviceX.NET/", "StockQuoteSoap12"); 
    public final static QName StockQuoteHttpGet = new QName("http://www.webserviceX.NET/", "StockQuoteHttpGet"); 
    static { 
     URL url = null; 
     try { 
      url = new URL("file:/home/axiopisty/projects/cxf-wsdl2java-example/src/main/resources/stockquote.wsdl"); 
     } catch (MalformedURLException e) { 
      java.util.logging.Logger.getLogger(StockQuote.class.getName()) 
       .log(java.util.logging.Level.INFO, 
        "Can not initialize the default wsdl from {0}", "file:/home/axiopisty/projects/cxf-wsdl2java-example/src/main/resources/stockquote.wsdl"); 
     } 
     WSDL_LOCATION = url; 
    } 

    public StockQuote(URL wsdlLocation) { 
     super(wsdlLocation, SERVICE); 
    } 

    public StockQuote(URL wsdlLocation, QName serviceName) { 
     super(wsdlLocation, serviceName); 
    } 

    public StockQuote() { 
     super(WSDL_LOCATION, SERVICE); 
    } 

    //This constructor requires JAX-WS API 2.2. You will need to endorse the 2.2 
    //API jar or re-run wsdl2java with "-frontend jaxws21" to generate JAX-WS 2.1 
    //compliant code instead. 
    public StockQuote(WebServiceFeature ... features) { 
     super(WSDL_LOCATION, SERVICE, features); 
    } 

    //This constructor requires JAX-WS API 2.2. You will need to endorse the 2.2 
    //API jar or re-run wsdl2java with "-frontend jaxws21" to generate JAX-WS 2.1 
    //compliant code instead. 
    public StockQuote(URL wsdlLocation, WebServiceFeature ... features) { 
     super(wsdlLocation, SERVICE, features); 
    } 

    //This constructor requires JAX-WS API 2.2. You will need to endorse the 2.2 
    //API jar or re-run wsdl2java with "-frontend jaxws21" to generate JAX-WS 2.1 
    //compliant code instead. 
    public StockQuote(URL wsdlLocation, QName serviceName, WebServiceFeature ... features) { 
     super(wsdlLocation, serviceName, features); 
    } 

    /** 
    * 
    * @return 
    *  returns StockQuoteHttpPost 
    */ 
    @WebEndpoint(name = "StockQuoteHttpPost") 
    public StockQuoteHttpPost getStockQuoteHttpPost() { 
     return super.getPort(StockQuoteHttpPost, StockQuoteHttpPost.class); 
    } 

    /** 
    * 
    * @param features 
    *  A list of {@link javax.xml.ws.WebServiceFeature} to configure on the proxy. Supported features not in the <code>features</code> parameter will have their default values. 
    * @return 
    *  returns StockQuoteHttpPost 
    */ 
    @WebEndpoint(name = "StockQuoteHttpPost") 
    public StockQuoteHttpPost getStockQuoteHttpPost(WebServiceFeature... features) { 
     return super.getPort(StockQuoteHttpPost, StockQuoteHttpPost.class, features); 
    } 
    /** 
    * 
    * @return 
    *  returns StockQuoteSoap 
    */ 
    @WebEndpoint(name = "StockQuoteSoap") 
    public StockQuoteSoap getStockQuoteSoap() { 
     return super.getPort(StockQuoteSoap, StockQuoteSoap.class); 
    } 

    /** 
    * 
    * @param features 
    *  A list of {@link javax.xml.ws.WebServiceFeature} to configure on the proxy. Supported features not in the <code>features</code> parameter will have their default values. 
    * @return 
    *  returns StockQuoteSoap 
    */ 
    @WebEndpoint(name = "StockQuoteSoap") 
    public StockQuoteSoap getStockQuoteSoap(WebServiceFeature... features) { 
     return super.getPort(StockQuoteSoap, StockQuoteSoap.class, features); 
    } 
    /** 
    * 
    * @return 
    *  returns StockQuoteSoap 
    */ 
    @WebEndpoint(name = "StockQuoteSoap12") 
    public StockQuoteSoap getStockQuoteSoap12() { 
     return super.getPort(StockQuoteSoap12, StockQuoteSoap.class); 
    } 

    /** 
    * 
    * @param features 
    *  A list of {@link javax.xml.ws.WebServiceFeature} to configure on the proxy. Supported features not in the <code>features</code> parameter will have their default values. 
    * @return 
    *  returns StockQuoteSoap 
    */ 
    @WebEndpoint(name = "StockQuoteSoap12") 
    public StockQuoteSoap getStockQuoteSoap12(WebServiceFeature... features) { 
     return super.getPort(StockQuoteSoap12, StockQuoteSoap.class, features); 
    } 
    /** 
    * 
    * @return 
    *  returns StockQuoteHttpGet 
    */ 
    @WebEndpoint(name = "StockQuoteHttpGet") 
    public StockQuoteHttpGet getStockQuoteHttpGet() { 
     return super.getPort(StockQuoteHttpGet, StockQuoteHttpGet.class); 
    } 

    /** 
    * 
    * @param features 
    *  A list of {@link javax.xml.ws.WebServiceFeature} to configure on the proxy. Supported features not in the <code>features</code> parameter will have their default values. 
    * @return 
    *  returns StockQuoteHttpGet 
    */ 
    @WebEndpoint(name = "StockQuoteHttpGet") 
    public StockQuoteHttpGet getStockQuoteHttpGet(WebServiceFeature... features) { 
     return super.getPort(StockQuoteHttpGet, StockQuoteHttpGet.class, features); 
    } 
} 

편집 여기 2017년 9월 11일

은 이제까지 그것을 제공하는 웹 사이트가 사라질 경우를의 WSDL 파일의 내용이다.

stockquote.wsdl : 당신이 포트를 얻을 때

<?xml version="1.0" encoding="utf-8"?> 
<wsdl:definitions xmlns:tm="http://microsoft.com/wsdl/mime/textMatching/" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" xmlns:mime="http://schemas.xmlsoap.org/wsdl/mime/" xmlns:tns="http://www.webserviceX.NET/" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:s="http://www.w3.org/2001/XMLSchema" xmlns:soap12="http://schemas.xmlsoap.org/wsdl/soap12/" xmlns:http="http://schemas.xmlsoap.org/wsdl/http/" targetNamespace="http://www.webserviceX.NET/" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"> 
    <wsdl:types> 
    <s:schema elementFormDefault="qualified" targetNamespace="http://www.webserviceX.NET/"> 
     <s:element name="GetQuote"> 
     <s:complexType> 
      <s:sequence> 
      <s:element minOccurs="0" maxOccurs="1" name="symbol" type="s:string" /> 
      </s:sequence> 
     </s:complexType> 
     </s:element> 
     <s:element name="GetQuoteResponse"> 
     <s:complexType> 
      <s:sequence> 
      <s:element minOccurs="0" maxOccurs="1" name="GetQuoteResult" type="s:string" /> 
      </s:sequence> 
     </s:complexType> 
     </s:element> 
     <s:element name="string" nillable="true" type="s:string" /> 
    </s:schema> 
    </wsdl:types> 
    <wsdl:message name="GetQuoteSoapIn"> 
    <wsdl:part name="parameters" element="tns:GetQuote" /> 
    </wsdl:message> 
    <wsdl:message name="GetQuoteSoapOut"> 
    <wsdl:part name="parameters" element="tns:GetQuoteResponse" /> 
    </wsdl:message> 
    <wsdl:message name="GetQuoteHttpGetIn"> 
    <wsdl:part name="symbol" type="s:string" /> 
    </wsdl:message> 
    <wsdl:message name="GetQuoteHttpGetOut"> 
    <wsdl:part name="Body" element="tns:string" /> 
    </wsdl:message> 
    <wsdl:message name="GetQuoteHttpPostIn"> 
    <wsdl:part name="symbol" type="s:string" /> 
    </wsdl:message> 
    <wsdl:message name="GetQuoteHttpPostOut"> 
    <wsdl:part name="Body" element="tns:string" /> 
    </wsdl:message> 
    <wsdl:portType name="StockQuoteSoap"> 
    <wsdl:operation name="GetQuote"> 
     <wsdl:documentation xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/">Get Stock quote for a company Symbol</wsdl:documentation> 
     <wsdl:input message="tns:GetQuoteSoapIn" /> 
     <wsdl:output message="tns:GetQuoteSoapOut" /> 
    </wsdl:operation> 
    </wsdl:portType> 
    <wsdl:portType name="StockQuoteHttpGet"> 
    <wsdl:operation name="GetQuote"> 
     <wsdl:documentation xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/">Get Stock quote for a company Symbol</wsdl:documentation> 
     <wsdl:input message="tns:GetQuoteHttpGetIn" /> 
     <wsdl:output message="tns:GetQuoteHttpGetOut" /> 
    </wsdl:operation> 
    </wsdl:portType> 
    <wsdl:portType name="StockQuoteHttpPost"> 
    <wsdl:operation name="GetQuote"> 
     <wsdl:documentation xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/">Get Stock quote for a company Symbol</wsdl:documentation> 
     <wsdl:input message="tns:GetQuoteHttpPostIn" /> 
     <wsdl:output message="tns:GetQuoteHttpPostOut" /> 
    </wsdl:operation> 
    </wsdl:portType> 
    <wsdl:binding name="StockQuoteSoap" type="tns:StockQuoteSoap"> 
    <soap:binding transport="http://schemas.xmlsoap.org/soap/http" /> 
    <wsdl:operation name="GetQuote"> 
     <soap:operation soapAction="http://www.webserviceX.NET/GetQuote" style="document" /> 
     <wsdl:input> 
     <soap:body use="literal" /> 
     </wsdl:input> 
     <wsdl:output> 
     <soap:body use="literal" /> 
     </wsdl:output> 
    </wsdl:operation> 
    </wsdl:binding> 
    <wsdl:binding name="StockQuoteSoap12" type="tns:StockQuoteSoap"> 
    <soap12:binding transport="http://schemas.xmlsoap.org/soap/http" /> 
    <wsdl:operation name="GetQuote"> 
     <soap12:operation soapAction="http://www.webserviceX.NET/GetQuote" style="document" /> 
     <wsdl:input> 
     <soap12:body use="literal" /> 
     </wsdl:input> 
     <wsdl:output> 
     <soap12:body use="literal" /> 
     </wsdl:output> 
    </wsdl:operation> 
    </wsdl:binding> 
    <wsdl:binding name="StockQuoteHttpGet" type="tns:StockQuoteHttpGet"> 
    <http:binding verb="GET" /> 
    <wsdl:operation name="GetQuote"> 
     <http:operation location="/GetQuote" /> 
     <wsdl:input> 
     <http:urlEncoded /> 
     </wsdl:input> 
     <wsdl:output> 
     <mime:mimeXml part="Body" /> 
     </wsdl:output> 
    </wsdl:operation> 
    </wsdl:binding> 
    <wsdl:binding name="StockQuoteHttpPost" type="tns:StockQuoteHttpPost"> 
    <http:binding verb="POST" /> 
    <wsdl:operation name="GetQuote"> 
     <http:operation location="/GetQuote" /> 
     <wsdl:input> 
     <mime:content type="application/x-www-form-urlencoded" /> 
     </wsdl:input> 
     <wsdl:output> 
     <mime:mimeXml part="Body" /> 
     </wsdl:output> 
    </wsdl:operation> 
    </wsdl:binding> 
    <wsdl:service name="StockQuote"> 
    <wsdl:port name="StockQuoteSoap" binding="tns:StockQuoteSoap"> 
     <soap:address location="http://www.webservicex.net/stockquote.asmx" /> 
    </wsdl:port> 
    <wsdl:port name="StockQuoteSoap12" binding="tns:StockQuoteSoap12"> 
     <soap12:address location="http://www.webservicex.net/stockquote.asmx" /> 
    </wsdl:port> 
    <wsdl:port name="StockQuoteHttpGet" binding="tns:StockQuoteHttpGet"> 
     <http:address location="http://www.webservicex.net/stockquote.asmx" /> 
    </wsdl:port> 
    <wsdl:port name="StockQuoteHttpPost" binding="tns:StockQuoteHttpPost"> 
     <http:address location="http://www.webservicex.net/stockquote.asmx" /> 
    </wsdl:port> 
    </wsdl:service> 
</wsdl:definitions> 
당신은 당신의 서비스 '클래스 (WebReportsService 내가 생각) getPort를 사용하여 포트 무도회를 얻어야한다
+0

당신은 그것이 필요한 방식으로 모든 것을 인스턴스화하여 메인 클래스를 만들 것이라고 말하고 있습니까? –

+1

예, 일종의입니다. 그것은 단지 스텁 클라이언트입니다. 따라서 실제 데이터로 객체를 채워야하지만 생성 된 스텁 클라이언트는 생성 된 코드를 사용하는 좋은 예를 보여줍니다. – axiopisty

+1

감사합니다. 내 일을 저장했습니다. 매우 유용합니다. – Jangid