SORU
12 Kasım 2010, Cuma


JAX-WS client :'in ne erişmek için doğru yolu yerel WSDL?

Bu önemsiz bir soru olacak sanırım ama tüm yolları deniyor çok zaman geçirdikten sonra vazgeçtim.
Sorun sağlanmış ben bir dosyadan bir web hizmeti istemci kurmak gerekiyor. Yerel dosya sisteminde bu dosya depoluyordum ve ben WSDL doğru dosya sisteminde dosya klasörü devam ederken, her şey yolunda. Ben bir sunucuya dağıtmak veya dosya sisteminden WSDL Kaldır klasörünü proxy WSDL bulamıyor ve hata yükselir. Web aradım ve aşağıdaki mesajlar buldum henüz o iş yapmak mümkün değilim:
JAX-WS Loading WSDL from jar
http://www.java.net/forum/topic/glassfish/metro-and-jaxb/client-jar-cant-find-local-wsdl-0
http://blog.vinodsingh.com/2008/12/locally-packaged-wsdl.html

Eclipse 6.1 (bu bu yeni web hizmeti istemci ile güncelleme yaptım eski bir uygulama) kullanıyorum. Aşağıda JAX-WS proxy sınıfı :

    @WebServiceClient(name = "SOAService", targetNamespace = "http://soaservice.eci.ibm.com/", wsdlLocation = "file:/C:/local/path/to/wsdl/SOAService.wsdl")
public class SOAService
    extends Service
{

    private final static URL SOASERVICE_WSDL_LOCATION;
    private final static Logger logger = Logger.getLogger(com.ibm.eci.soaservice.SOAService.class.getName());

    static {
        URL url = null;
        try {
            URL baseUrl;
            baseUrl = com.ibm.eci.soaservice.SOAService.class.getResource(".");
            url = new URL(baseUrl, "file:/C:/local/path/to/wsdl/SOAService.wsdl");
        } catch (MalformedURLException e) {
            logger.warning("Failed to create URL for the wsdl Location: 'file:/C:/local/path/to/wsdl/SOAService.wsdl', retrying as a local file");
            logger.warning(e.getMessage());
        }
        SOASERVICE_WSDL_LOCATION = url;
    }

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

    public SOAService() {
        super(SOASERVICE_WSDL_LOCATION, new QName("http://soaservice.eci.ibm.com/", "SOAService"));
    }

    /**
     * 
     * @return
     *     returns SOAServiceSoap
     */
    @WebEndpoint(name = "SOAServiceSOAP")
    public SOAServiceSoap getSOAServiceSOAP() {
        return super.getPort(new QName("http://soaservice.eci.ibm.com/", "SOAServiceSOAP"), SOAServiceSoap.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 SOAServiceSoap
     */
    @WebEndpoint(name = "SOAServiceSOAP")
    public SOAServiceSoap getSOAServiceSOAP(WebServiceFeature... features) {
        return super.getPort(new QName("http://soaservice.eci.ibm.com/", "SOAServiceSOAP"), SOAServiceSoap.class, features);
    }

}


Bu proxy kullanmak için benim kod :

      WebServiceClient annotation = SOAService.class.getAnnotation(WebServiceClient.class);
//trying to replicate proxy settings
               URL baseUrl = com.ibm.eci.soaservice.SOAService.class.getResource("");//note : proxy uses "."
               URL url = new URL(baseUrl, "/WEB-INF/wsdl/client/SOAService.wsdl");
               //URL wsdlUrl = this.getClass().getResource("/META-INF/wsdl/SOAService.wsdl"); 
               SOAService serviceObj = new SOAService(url, new QName(annotation.targetNamespace(), annotation.name()));
               proxy = serviceObj.getSOAServiceSOAP();
               /* baseUrl;

               //classes\com\ibm\eci\soaservice
               //URL url = new URL(baseUrl, "../../../../wsdl/SOAService.wsdl");

               proxy = new SOAService().getSOAServiceSOAP();*/
               //updating service endpoint 
               Map<String, Object> ctxt = ((BindingProvider)proxy ).getRequestContext();
               ctxt.put(JAXWSProperties.HTTP_CLIENT_STREAMING_CHUNK_SIZE, 8192);
               ctxt.put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY, WebServiceUrl);

Sen WSDL bir kopyasını koymakweb-ınf/wsdl/istemci/SOAServiceeklemek istemiyorumMETA-INFçok. Hizmet sınıflarıWEB-INF//sınıflar com/ıbm/ecı/soaservice/ve baseurl değişken (c:\path\to\the\project...\soaservice ) dosya tam yolunu içerir. Yukarıdaki kod hata üretir:
javax.xml.ws.WebServiceException: Failed to access the WSDL at: file:/WEB-INF/wsdl/client/SOAService.wsdl. It failed with: \WEB-INF\wsdl\client\SOAService.wsdl (cannot find the path).

Öncelikle, proxy sınıfının wsdllocation güncelleme miyim? Nasıl WEB-INF/sınıflar com/ıbm/ecı/soaservice \WSDL için arama yapmak için WEB-INF\client\\wsdl/SOAService.SOAService sınıf söylerim o zaman wsdl?

Şimdiden teşekkür ederim.

DÜZENLENMİŞBu link başka bir sınıf içine WSDL koymak için ki - http://jianmingli.com/wp/?cat=41, buldum. Sormaya utanıyorum: nasıl web uygulama sınıf içine koyayım mı?

CEVAP
14 Kasım 2010, Pazar


En iyi seçenek jax-ws-catalog.xml kullanmaktır

Yerel WSDL dosyasını derlerken , WSDL konumu geçersiz kılar ve böyle bir şey için ayarlayın

http://localhost/wsdl/SOAService.wsdl

Bu merak etme sadece bir URI ve URL değil , WSDL adresi boş olması gerekmez anlamına gelir.
Derleyici java için wsdl için wsdllocation seçenek geçerek bunu yapabilirsiniz.

Bu sayede proxy kod değişecektir

static {
    URL url = null;
    try {
        URL baseUrl;
        baseUrl = com.ibm.eci.soaservice.SOAService.class.getResource(".");
        url = new URL(baseUrl, "file:/C:/local/path/to/wsdl/SOAService.wsdl");
    } catch (MalformedURLException e) {
        logger.warning("Failed to create URL for the wsdl Location: 'file:/C:/local/path/to/wsdl/SOAService.wsdl', retrying as a local file");
        logger.warning(e.getMessage());
    }
    SOASERVICE_WSDL_LOCATION = url;
}

için

static {
    URL url = null;
    try {
        URL baseUrl;
        baseUrl = com.ibm.eci.soaservice.SOAService.class.getResource(".");
        url = new URL(baseUrl, "http://localhost/wsdl/SOAService.wsdl");
    } catch (MalformedURLException e) {
        logger.warning("Failed to create URL for the wsdl Location: 'http://localhost/wsdl/SOAService.wsdl', retrying as a local file");
        logger.warning(e.getMessage());
    }
    SOASERVICE_WSDL_LOCATION = url;
}

File:// http:// değiştirildi URL oluşturucu dikkat edin.

Şimdi jax-ws-catalog.xml geliyor. Jax-ws jax-ws-catalog.xml nitekim *5 konum*WSDL yüklemek için çalışacağız olmadan ve başarısız, böyle bir WSDL kullanılabilir olacaktır.

Ama jax-ws-catalog.xml ile WSDL erişmeye çalışır zaman yerel bir paket için WSDL jax-ws yönlendirebilirsiniz @

http://localhost/wsdl/SOAService.wsdl
.

Burada jax-ws-catalog.xml

<catalog xmlns="urn:oasis:names:tc:entity:xmlns:xml:catalog" prefer="system">
        <system systemId="http://localhost/wsdl/SOAService.wsdl"
                uri="wsdl/SOAService.wsdl"/>
    </catalog>

Ne yapıyorsun

http://localhost/wsdl/SOAService.wsdl
, WSDL yüklenmesi gerekiyor hiç zaman yerel yol wsdl/SOAService gelen yük gerektiğini jax-ws söylüyor.wsdl.

Şimdi nerede wsdl/SOAService koymak gerekir.XML jax-ws-catalog.xml ? Bu milyon dolarlık bir soru değil mi ?
Başvuru kavanoz META-INF dizini içinde olmalıdır.

bunun gibi bir şey yani

ABCD.jar  
|__ META-INF    
    |__ jax-ws-catalog.xml  
    |__ wsdl  
        |__ SOAService.wsdl  

Bu şekilde bile proxy erişimi olan müvekkilin URL geçersiz kılmak zorunda değilsiniz. WSDL senin KAVANOZ içinde gelen çekilir, ve kodlanmış kod içinde dosya yolları var zorunda kalmamak.

Daha fazla bilgi jax-ws-catalog.xml üzerinde http://jax-ws.java.net/nonav/2.1.2m1/docs/catalog-support.html

Bu yardımcı olur umarım

Bunu Paylaş:
  • Google+
  • E-Posta
Etiketler:

YORUMLAR

SPONSOR VİDEO

Rastgele Yazarlar

  • 8lacKy

    8lacKy

    30 Mart 2009
  • bunliu

    bunliu

    2 Mayıs 2007
  • Sergio Lafuente Rubio

    Sergio Lafue

    11 Aralık 2008