<rt id="bn8ez"></rt>
<label id="bn8ez"></label>

  • <span id="bn8ez"></span>

    <label id="bn8ez"><meter id="bn8ez"></meter></label>

    天道酬勤

    點點滴滴的足跡,幻化成漫天的云彩
    posts - 22, comments - 0, trackbacks - 0, articles - 2
      BlogJava :: 首頁 :: 新隨筆 :: 聯系 :: 聚合  :: 管理

    AXIS技術的一個問題

    Posted on 2011-07-17 01:01 匆匆過客 閱讀(4410) 評論(0)  編輯  收藏 所屬分類: Java
    前天做技術交流,有一位同仁針對下面的一段AXIS客戶端代碼提出了這樣的問題:QName qname=new QName("SparePartDetails","SparePartBean");這2個參數是什么意義?

     1         String endpointURL = "http://localhost:8080/ws/services/SparePartService";
     2         String methodName = "getSparepart";
     3 
     4         Service service = new Service();
     5         Call call = (Call) service.createCall();
     6         call.setTargetEndpointAddress(new java.net.URL(endpointURL));
     7         call.setOperationName(new QName("SparePartService", methodName));
     8 
     9         call.addParameter("sku", XMLType.XSD_STRING, ParameterMode.IN);
    10 
    11         QName qname = new QName("SparePartDetails""SparePartBean");
    12         Class cls = org.bluebear.ws.advanced.customdatatype.SparePartBean.class;
    13         call.registerTypeMapping(cls, qname, BeanSerializerFactory.class, BeanDeserializerFactory.class);
    14         call.setReturnType(qname);
    15 
    16         Object[] params = new Object[] { "222222" };
    17         SparePartBean spBean = (SparePartBean) call.invoke(params);
    18 
    19         System.out.println(spBean);

    當時有的同仁回答說是根據WSDD中的beanMapping中的定義來確定的。這句話本身沒有錯,可是如果Service是.Net的語言寫的呢?或者Service不是通過AXIS來發布的呢?是否也有WSDD?

    1     <service name="SparePartService" provider="java:RPC">
    2         <parameter name="className"
    3                    value="org.bluebear.ws.advanced.customdatatype.service001.SparePartService" />
    4         <parameter name="allowMethods" 
    5                    value="getSparePart" />
    6         <beanMapping qname="blueBearNS:SparePartBean"
    7                      xmlns:blueBearNS="SparePartDetails"
    8                      languageSpecificType="java:org.bluebear.ws.advanced.customdatatype.SparePartBean" />
    9     </service>

    這個問題存留于我的腦海中。對于客戶端而言,只是需要知道如何將返回的SOAP XML 信息轉換成相應的JavaBean就可以了。對于Service而言,只是需要將JavaBean轉換成SOAP XML。所以客戶端的代碼應該和SOAP XML一致。為此我特地研究了2個方面的問題:
    1. QName的Constructor
    /**
         * <p><code>QName</code> constructor specifying the Namespace URI
         * and local part.</p>
         *
         * <p>If the Namespace URI is <code>null</code>, it is set to
         * {
    @link javax.xml.XMLConstants#NULL_NS_URI
         * XMLConstants.NULL_NS_URI}.  This value represents no
         * explicitly defined Namespace as defined by the <a
         * href="
    http://www.w3.org/TR/REC-xml-names/#ns-qualnames">Namespaces
         * in XML</a> specification.  This action preserves compatible
         * behavior with QName 1.0.  Explicitly providing the {
    @link
         * javax.xml.XMLConstants#NULL_NS_URI
         * XMLConstants.NULL_NS_URI} value is the preferred coding
         * style.</p>
         *
         * <p>If the local part is <code>null</code> an
         * <code>IllegalArgumentException</code> is thrown.
         * A local part of "" is allowed to preserve
         * compatible behavior with QName 1.0. </p>
         *
         * <p>When using this constructor, the prefix is set to {
    @link
         * javax.xml.XMLConstants#DEFAULT_NS_PREFIX
         * XMLConstants.DEFAULT_NS_PREFIX}.</p>
         *
         * <p>The Namespace URI is not validated as a
         * <a href="
    http://www.ietf.org/rfc/rfc2396.txt">URI reference</a>.
         * The local part is not validated as a
         * <a href="
    http://www.w3.org/TR/REC-xml-names/#NT-NCName">NCName</a>
         * as specified in <a href="
    http://www.w3.org/TR/REC-xml-names/">Namespaces
         * in XML</a>.</p>
         *
         * 
    @param namespaceURI Namespace URI of the <code>QName</code>
         * 
    @param localPart    local part of the <code>QName</code>
         *
         * 
    @throws IllegalArgumentException When <code>localPart</code> is
         *   <code>null</code>
         *
         * 
    @see #QName(String namespaceURI, String localPart, String
         * prefix) QName(String namespaceURI, String localPart, String
         * prefix)
         
    */
        
    public QName(final String namespaceURI, final String localPart) {
            
    this(namespaceURI, localPart, XMLConstants.DEFAULT_NS_PREFIX);
        }

    從上面的解釋中可以看出,QName的Constructor第一個參數是XML的namespace,第二個參數是該namepace下的一個名字。所以對于客戶端的代碼而言,QName qname=new QName("SparePartDetails","SparePartBean");所定義的這兩個參數第一個是SparetDetails是namespace,第二個SparePartBean是JavaBean轉成XML,在XML中的名字。這個問題在Web Service中的WSDL中得到了驗證。

    2. WSDL代碼
    通過地址:http://localhost:8080/ws/services/SparePartService?wsdl ,即可看到。其中在wsdl:types節點的信息如下:

     <wsdl:types>
      
    <schema targetNamespace="SparePartDetails" xmlns="http://www.w3.org/2001/XMLSchema">
       
    <import namespace="http://schemas.xmlsoap.org/soap/encoding/"/>
       
    <complexType name="SparePartBean">
        
    <sequence>
         
    <element name="description" nillable="true" type="soapenc:string"/>
         
    <element name="price" type="xsd:float"/>
         
    <element name="sku" nillable="true" type="soapenc:string"/>
        
    </sequence>
       
    </complexType>
      
    </schema>
     
    </wsdl:types>

    其中詳細描述了SparePartDetails namespace下面存在一個因為SpartPartBean的XML 數據類型。這里詳細描述了當JavaBean轉成XML的時候,XML的數據結構。

    結論:
         位于AXIS Service的WSDD中的beanMapping規定了Service JavaBean轉成XML的時候,XML代碼所必須的的namespace和名字。當客戶端接到SOAP XML代碼時,必須使用那個namespace和名字才能將相應的XML代碼轉成JavaBean。所以客戶端的代碼的確只是和SOAP XML相關。
    主站蜘蛛池模板: 精品国产免费人成网站| 黄网站色成年片大免费高清| 免费日本一区二区| 亚洲精品无码久久久久sm| 黄视频在线观看免费| 亚洲高清无码在线观看| 人妻仑乱A级毛片免费看| 无码专区一va亚洲v专区在线| 亚洲av最新在线观看网址| 男女交性永久免费视频播放| 亚洲色偷精品一区二区三区| 免费无码看av的网站| 国产亚洲人成在线播放| 免费一级毛片在线观看| 一级毛片免费观看不收费| 亚洲人成无码网站| 外国成人网在线观看免费视频| 国产成人精品日本亚洲| 99热免费在线观看| 久久久久se色偷偷亚洲精品av| 四虎国产精品免费久久| 韩国亚洲伊人久久综合影院| 亚洲福利中文字幕在线网址| 中文字幕免费在线看| 久久久久久亚洲Av无码精品专口 | 巨胸喷奶水www永久免费| 亚洲精品成人片在线观看精品字幕| 中国一级特黄的片子免费 | 亚洲一级片在线观看| 国产成人综合久久精品免费| 国产成人精品免费大全| 亚洲AV无码成人专区片在线观看 | 美女免费视频一区二区| 亚洲日韩中文无码久久| 亚洲免费二区三区| 国产天堂亚洲精品| 亚洲国产精品lv| 情侣视频精品免费的国产| 黄色视频在线免费观看| 久久国产亚洲精品| 亚洲熟妇无码另类久久久|