2011-04-19 82 views
0

你好,我在Java深化发展的一些网络服务,所以我创建了一个WSDL文件来描述这个服务。数组元素的

随着我的WSDL创建Web服务(servcer侧)。但由于

我认为这个问题是

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:bil="http://tempuri.org/Services/" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/"> 
    <soapenv:Header/> 
    <soapenv:Body> 
     <bil:ArrayOfElement soapenc:arrayType="?" soapenc:offset="?" id="?" href="?"> 
     <!--1 or more repetitions:--> 
     <Element> 
      <code>?</code> 
      <codeElement>?</codeElement> 
      <TypeService>?</TypeService> 
     </Element> 
     </bil:ArrayOfElement> 
    </soapenv:Body> 
</soapenv:Envelope> 

其实,我不知道是什么,我们必须把这一行中我不能创建客户端:

<bil:ArrayOfElement soapenc:arrayType="?" soapenc:offset="?" id="?" href="?"> 

而且我的测试中,我发送此ENVELOPPE和它的作品(但像你看到它的另一个WSDL):

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:bil="http://tempuri.org/Services/"> 
    <soapenv:Header/> 
    <soapenv:Body> 
     <bil:ArrayOfElement> 
        <Element> 
       <code>exmepleCode</code> 
       <codeElement>exmempleCodeElement</codeElement> 
       <TypeService>a_Service_Type</TypeService> 
      </Element> 
     </bil:ArrayOfElement> 

     <!-- other elements--> 

    </soapenv:Body> 
</soapenv:Envelope> 

回答

0

你是如何创建的WSDL ?

在使用Web服务或xml架构(xsd)时,一个重要问题是在xsd和语言特定类型(本例中为java)之间没有简单的一对一映射。

蕴涵一个做一个“往返”映射时(Java来XSD,然后XSD到Java),你不要总是你开始 - 使用非简单的类型,比如数组或者有其他特别当容器。

在这种情况下的解决方案是创建一个“正确”的XSD架构,并从中获得客户端的javadefinitions从这个架构中的服务器 - 只有一个XSD到Java的转换已经完成,因此没有rount行程映射的问题遇到。 要创建这样一个XSD,您应该使用定义集合的本地方法在XSD,这基本上是添加minOccursmaxOccurs属性的基本元素。

你可以找到更详细的参考here

注意,你不必用手制作的XSD - 你也可以使用任何XSD编辑器(大多数现代IDE的有一个),以获得相同的结果。

+0

user709659 2011-04-26 19:04:54

+0

我的建议(作为一般的方法)是使用XSD编辑器创建一个新的XSD(不生成一个Java类的XSD)“?” - 并且从这个Java类(包括代理和存根) XSD。 – 2011-04-27 19:52:30

+0

好了,这是我真正做的,但我不创建一个XSD,但wsdl文件。我在eclipse中手动创建它。然后我生成类。 – user709659 2011-04-27 20:57:46