简体   繁体   English

使用axis2和java2wdsl在所有节点中重复命名空间

[英]Namespace repeated in all nodes using axis2 and java2wdsl

I am using eclipse and axis2 1.4.1 facet to generate a webservice. 我使用eclipse和axis2 1.4.1 facet生成一个web服务。 My problem is that in the generation process, the namespaces are being repeated in all nodes. 我的问题是在生成过程中,命名空间在所有节点中重复。 As you can see below, ns4 is repeated instead of being declared in NewOperationResponse node. 如下所示,重复ns4而不是在NewOperationResponse节点中声明。

How can I make java2wdsl (or eclipse) generate that automatically (only in parent node or top node) ? 如何使java2wdsl(或eclipse)自动生成(仅在父节点或顶级节点中)? Do I have to change anything on wsdl or xsd ? 我是否必须更改wsdl或xsd上的任何内容?

Thanks! 谢谢!

WS Response WS响应

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
<soapenv:Body>
<NewOperationResponse xmlns="http://www.example.org/Test">
<out>
  <ns4:areaCode xmlns:ns4="http://www.example.org/Test/Simple">0</ns4:areaCode> 
  <ns4:exchange xmlns:ns4="http://www.example.org/Test/Simple">0</ns4:exchange> 
  <ns4:number xmlns:ns4="http://www.example.org/Test/Simple">12</ns4:number> 
</out>
</NewOperationResponse>
</soapenv:Body>
</soapenv:Envelope>

WSDL WSDL

 <wsdl:types>

  <xsd:schema targetNamespace="http://www.example.org/Test"
   xmlns:simple="http://www.example.org/Test/Simple" 
   elementFormDefault="qualified" attributeFormDefault="unqualified" version="2.1">

   <xsd:import namespace="http://www.example.org/Test/Simple" schemaLocation="Simple.xsd" />
   <xsd:element name="NewOperation">
    <xsd:complexType>
     <xsd:sequence>
      <xsd:element name="in" type="xsd:string" />
     </xsd:sequence>
    </xsd:complexType>
   </xsd:element>

   <xsd:element name="NewOperationResponse">
    <xsd:complexType>
     <xsd:sequence>
      <xsd:element name="out" type="simple:Phone" />
     </xsd:sequence>
    </xsd:complexType>
   </xsd:element>

  </xsd:schema>
 </wsdl:types>

 <wsdl:message name="NewOperationRequest">
  <wsdl:part element="tns:NewOperation" name="parameters" />
 </wsdl:message>
 <wsdl:message name="NewOperationResponse">
  <wsdl:part element="tns:NewOperationResponse" name="parameters" />
 </wsdl:message>

 <wsdl:portType name="Test">
  <wsdl:operation name="NewOperation">
   <wsdl:input message="tns:NewOperationRequest" />
   <wsdl:output message="tns:NewOperationResponse" />
  </wsdl:operation>
 </wsdl:portType>
 <wsdl:binding name="TestSOAP" type="tns:Test">
  <soap:binding style="document"
   transport="http://schemas.xmlsoap.org/soap/http" />
  <wsdl:operation name="NewOperation">
   <soap:operation soapAction="" />
   <wsdl:input>
    <soap:body use="literal" />
   </wsdl:input>
   <wsdl:output>
    <soap:body use="literal" />
   </wsdl:output>
  </wsdl:operation>
 </wsdl:binding>
 <wsdl:service name="Test">
  <wsdl:port binding="tns:TestSOAP" name="TestSOAP">
   <soap:address location="http://localhost:8084/WSDLProject/services/Test" />
  </wsdl:port>
 </wsdl:service>
</wsdl:definitions>

simple.xsd simple.xsd

<?xml version="1.0" encoding="UTF-8"?>
<xs:schema targetNamespace="http://www.example.org/Test/Simple"
 xmlns:xs="http://www.w3.org/2001/XMLSchema" 
 elementFormDefault="qualified"
 attributeFormDefault="qualified">

 <xs:complexType name="Phone">
  <xs:sequence>
   <xs:element name="areaCode" type="xs:int" />
   <xs:element name="exchange" type="xs:int" />
   <xs:element name="number" type="xs:int" />
  </xs:sequence>
 </xs:complexType>
</xs:schema>

and what about adding 加入怎么样?

<schema elementFormDefaultQualified="false"/> 

inside

<service>

in your services.xml ? 在您的services.xml中

At least this worked for me, as you can see from the SOAP response: 至少这对我有用,正如您从SOAP响应中看到的那样:

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"><soapenv:Body><ns:getTelalertByEscalationResponse xmlns:ns="http://ofrick.com"><return xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="ax237:TelalertEntry"><alertDefName xsi:nil="true" /><alertId>1234</alertId><client>cwp1088</client><timeStamp>201405202254</timeStamp><tts>and this is a test tts</tts></return></ns:getTelalertByEscalationResponse></soapenv:Body></soapenv:Envelope>

在你的wsdl模式声明中切换到使用elementFormDefault="uqualified"而不是使用elementFormDefault =“qualified”

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM