wsdl 互操作性问题

发布于 2024-08-29 22:06:12 字数 6233 浏览 5 评论 0原文

我编写了一个 .asmx Web 服务,我试图从 java 客户端使用它。我正在使用 axis2 的 wsdl2java 来生成代码。但它说 wsdl 无效。这里到底有什么问题呢?毕竟是.net自动生成了wsdl。 wsdl 标准是否存在问题,而不是缺乏标准?我现在能做什么?

我将 wsdl 放在这里以供参考。

<?xml version="1.0" encoding="utf-8"?>
<wsdl:definitions xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" 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://localhost:4148/" 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://localhost:4148/" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/">
  <wsdl:types>
    <s:schema elementFormDefault="qualified" targetNamespace="http://localhost:4148/">
      <s:element name="GetUser">
        <s:complexType>
          <s:sequence>
            <s:element minOccurs="0" maxOccurs="1" name="uid" type="s:string" />
          </s:sequence>
        </s:complexType>
      </s:element>
      <s:element name="GetUserResponse">
        <s:complexType>
          <s:sequence>
            <s:element minOccurs="0" maxOccurs="1" name="GetUserResult" type="tns:User" />
          </s:sequence>
        </s:complexType>
      </s:element>
      <s:complexType name="User">
        <s:sequence>
          <s:element minOccurs="0" maxOccurs="1" name="HA" type="tns:ComplexT" />
          <s:element minOccurs="0" maxOccurs="1" name="AP" type="s:string" />
          <s:element minOccurs="0" maxOccurs="1" name="AL" type="tns:ArrayOfString" />
          <s:element minOccurs="0" maxOccurs="1" name="CO" type="s:string" />
          <s:element minOccurs="0" maxOccurs="1" name="EP" type="s:string" />
          <s:element minOccurs="0" maxOccurs="1" name="ND" type="s:string" />
          <s:element minOccurs="0" maxOccurs="1" name="AE" type="s:string" />
          <s:element minOccurs="0" maxOccurs="1" name="IE" type="s:string" />
          <s:element minOccurs="0" maxOccurs="1" name="IN" type="s:string" />
          <s:element minOccurs="0" maxOccurs="1" name="HM" type="s:string" />
          <s:element minOccurs="0" maxOccurs="1" name="AN" type="s:string" />
          <s:element minOccurs="0" maxOccurs="1" name="MI" type="tns:ArrayOfString" />
          <s:element minOccurs="0" maxOccurs="1" name="NO" type="s:string" />
          <s:element minOccurs="0" maxOccurs="1" name="TL" type="s:string" />
          <s:element minOccurs="0" maxOccurs="1" name="UI" type="s:string" />
          <s:element minOccurs="0" maxOccurs="1" name="DT" type="s:string" />
          <s:element minOccurs="0" maxOccurs="1" name="PT" type="s:string" />
          <s:element minOccurs="0" maxOccurs="1" name="PO" type="s:string" />
          <s:element minOccurs="0" maxOccurs="1" name="AE" type="s:string" />
          <s:element minOccurs="0" maxOccurs="1" name="ME" type="tns:ArrayOfString" />
        </s:sequence>
      </s:complexType>
      <s:complexType name="ComplexT">
        <s:sequence>
          <s:element minOccurs="0" maxOccurs="1" name="SR" type="s:string" />
          <s:element minOccurs="0" maxOccurs="1" name="CI" type="s:string" />
          <s:element minOccurs="0" maxOccurs="1" name="TA" type="s:string" />
          <s:element minOccurs="0" maxOccurs="1" name="SC" type="s:string" />
          <s:element minOccurs="0" maxOccurs="1" name="RU" type="s:string" />
          <s:element minOccurs="0" maxOccurs="1" name="HN" type="s:string" />
        </s:sequence>
      </s:complexType>
      <s:complexType name="ArrayOfString">
        <s:sequence>
          <s:element minOccurs="0" maxOccurs="unbounded" name="string" nillable="true" type="s:string" />
        </s:sequence>
      </s:complexType>
    </s:schema>
  </wsdl:types>
  <wsdl:message name="GetUserSoapIn">
    <wsdl:part name="parameters" element="tns:GetUser" />
  </wsdl:message>
  <wsdl:message name="GetUserSoapOut">
    <wsdl:part name="parameters" element="tns:GetUserResponse" />
  </wsdl:message>
  <wsdl:portType name="UserServiceSoap">
    <wsdl:operation name="GetUser">
      <wsdl:input message="tns:GetUserSoapIn" />
      <wsdl:output message="tns:GetUserSoapOut" />
    </wsdl:operation>
  </wsdl:portType>
  <wsdl:binding name="UserServiceSoap" type="tns:UserServiceSoap">
    <soap:binding transport="http://schemas.xmlsoap.org/soap/http" />
    <wsdl:operation name="GetUser">
      <soap:operation soapAction="http://localhost:4148/GetUser" 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="UserServiceSoap12" type="tns:UserServiceSoap">
    <soap12:binding transport="http://schemas.xmlsoap.org/soap/http" />
    <wsdl:operation name="GetUser">
      <soap12:operation soapAction="http://localhost:4148/GetUser" style="document" />
      <wsdl:input>
        <soap12:body use="literal" />
      </wsdl:input>
      <wsdl:output>
        <soap12:body use="literal" />
      </wsdl:output>
    </wsdl:operation>
  </wsdl:binding>
  <wsdl:service name="UserService">
    <wsdl:port name="UserServiceSoap" binding="tns:UserServiceSoap">
      <soap:address location="http://localhost:4148/Service/UserService.asmx" />
    </wsdl:port>
    <wsdl:port name="UserServiceSoap12" binding="tns:UserServiceSoap12">
      <soap12:address location="http://localhost:4148/Service/UserService.asmx" />
    </wsdl:port>
  </wsdl:service>
</wsdl:definitions>

I wrote a .asmx web service which I'm trying to consume from a java client. I'm using axis2's wsdl2java to generate code. But it says that the wsdl is invalid. What exactly is the problem here? It is .net which generated the wsdl automatically after all. Are there problems with wsdl standards, rather the lack of them? What can I do now?

I'm putting the wsdl here for reference.

<?xml version="1.0" encoding="utf-8"?>
<wsdl:definitions xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" 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://localhost:4148/" 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://localhost:4148/" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/">
  <wsdl:types>
    <s:schema elementFormDefault="qualified" targetNamespace="http://localhost:4148/">
      <s:element name="GetUser">
        <s:complexType>
          <s:sequence>
            <s:element minOccurs="0" maxOccurs="1" name="uid" type="s:string" />
          </s:sequence>
        </s:complexType>
      </s:element>
      <s:element name="GetUserResponse">
        <s:complexType>
          <s:sequence>
            <s:element minOccurs="0" maxOccurs="1" name="GetUserResult" type="tns:User" />
          </s:sequence>
        </s:complexType>
      </s:element>
      <s:complexType name="User">
        <s:sequence>
          <s:element minOccurs="0" maxOccurs="1" name="HA" type="tns:ComplexT" />
          <s:element minOccurs="0" maxOccurs="1" name="AP" type="s:string" />
          <s:element minOccurs="0" maxOccurs="1" name="AL" type="tns:ArrayOfString" />
          <s:element minOccurs="0" maxOccurs="1" name="CO" type="s:string" />
          <s:element minOccurs="0" maxOccurs="1" name="EP" type="s:string" />
          <s:element minOccurs="0" maxOccurs="1" name="ND" type="s:string" />
          <s:element minOccurs="0" maxOccurs="1" name="AE" type="s:string" />
          <s:element minOccurs="0" maxOccurs="1" name="IE" type="s:string" />
          <s:element minOccurs="0" maxOccurs="1" name="IN" type="s:string" />
          <s:element minOccurs="0" maxOccurs="1" name="HM" type="s:string" />
          <s:element minOccurs="0" maxOccurs="1" name="AN" type="s:string" />
          <s:element minOccurs="0" maxOccurs="1" name="MI" type="tns:ArrayOfString" />
          <s:element minOccurs="0" maxOccurs="1" name="NO" type="s:string" />
          <s:element minOccurs="0" maxOccurs="1" name="TL" type="s:string" />
          <s:element minOccurs="0" maxOccurs="1" name="UI" type="s:string" />
          <s:element minOccurs="0" maxOccurs="1" name="DT" type="s:string" />
          <s:element minOccurs="0" maxOccurs="1" name="PT" type="s:string" />
          <s:element minOccurs="0" maxOccurs="1" name="PO" type="s:string" />
          <s:element minOccurs="0" maxOccurs="1" name="AE" type="s:string" />
          <s:element minOccurs="0" maxOccurs="1" name="ME" type="tns:ArrayOfString" />
        </s:sequence>
      </s:complexType>
      <s:complexType name="ComplexT">
        <s:sequence>
          <s:element minOccurs="0" maxOccurs="1" name="SR" type="s:string" />
          <s:element minOccurs="0" maxOccurs="1" name="CI" type="s:string" />
          <s:element minOccurs="0" maxOccurs="1" name="TA" type="s:string" />
          <s:element minOccurs="0" maxOccurs="1" name="SC" type="s:string" />
          <s:element minOccurs="0" maxOccurs="1" name="RU" type="s:string" />
          <s:element minOccurs="0" maxOccurs="1" name="HN" type="s:string" />
        </s:sequence>
      </s:complexType>
      <s:complexType name="ArrayOfString">
        <s:sequence>
          <s:element minOccurs="0" maxOccurs="unbounded" name="string" nillable="true" type="s:string" />
        </s:sequence>
      </s:complexType>
    </s:schema>
  </wsdl:types>
  <wsdl:message name="GetUserSoapIn">
    <wsdl:part name="parameters" element="tns:GetUser" />
  </wsdl:message>
  <wsdl:message name="GetUserSoapOut">
    <wsdl:part name="parameters" element="tns:GetUserResponse" />
  </wsdl:message>
  <wsdl:portType name="UserServiceSoap">
    <wsdl:operation name="GetUser">
      <wsdl:input message="tns:GetUserSoapIn" />
      <wsdl:output message="tns:GetUserSoapOut" />
    </wsdl:operation>
  </wsdl:portType>
  <wsdl:binding name="UserServiceSoap" type="tns:UserServiceSoap">
    <soap:binding transport="http://schemas.xmlsoap.org/soap/http" />
    <wsdl:operation name="GetUser">
      <soap:operation soapAction="http://localhost:4148/GetUser" 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="UserServiceSoap12" type="tns:UserServiceSoap">
    <soap12:binding transport="http://schemas.xmlsoap.org/soap/http" />
    <wsdl:operation name="GetUser">
      <soap12:operation soapAction="http://localhost:4148/GetUser" style="document" />
      <wsdl:input>
        <soap12:body use="literal" />
      </wsdl:input>
      <wsdl:output>
        <soap12:body use="literal" />
      </wsdl:output>
    </wsdl:operation>
  </wsdl:binding>
  <wsdl:service name="UserService">
    <wsdl:port name="UserServiceSoap" binding="tns:UserServiceSoap">
      <soap:address location="http://localhost:4148/Service/UserService.asmx" />
    </wsdl:port>
    <wsdl:port name="UserServiceSoap12" binding="tns:UserServiceSoap12">
      <soap12:address location="http://localhost:4148/Service/UserService.asmx" />
    </wsdl:port>
  </wsdl:service>
</wsdl:definitions>

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

野の 2024-09-05 22:06:12

我能够正确处理您的 WSDL:

$ $AXIS2_HOME/bin/wsdl2java.sh -d adb -s -o build -uri test.wsdl
 Using AXIS2_HOME:   /opt/axis2-1.5.1
 Using JAVA_HOME:       /usr/lib/jvm/java-6-sun
Retrieving document at 'test.wsdl'.

$ find build -type f
build/src/localhost/UserServiceStub.java
build/build.xml

您使用的是哪个版本的 Axis2?

I was able to process your WSDL without error:

$ $AXIS2_HOME/bin/wsdl2java.sh -d adb -s -o build -uri test.wsdl
 Using AXIS2_HOME:   /opt/axis2-1.5.1
 Using JAVA_HOME:       /usr/lib/jvm/java-6-sun
Retrieving document at 'test.wsdl'.

$ find build -type f
build/src/localhost/UserServiceStub.java
build/build.xml

What version of Axis2 are you using?

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文