简体   繁体   English

在Tomcat上部署时SOAPFaultException但在GlassFish中工作正常

[英]SOAPFaultException when deployed on Tomcat but works fine in GlassFish

Friends, I have been trying a lot and read many forums but unable to understand why this issue is coming up. 朋友们,我一直在努力阅读很多论坛但却无法理解为什么会出现这个问题。
I created a Jax-WS WebService using contract first approach. 我使用契约优先方法创建了一个Jax-WS WebService。 Created WSDL & XSD and then used wsimport tool to generate rest of the artifacts, provided implementation for SEI. 创建了WSDL和XSD,然后使用wsimport工具生成其余的工件,为SEI提供了实现。

Deployed the WebService application to GlassFish in Eclipse Helios (Glassfish adapter and plugin installed in Eclipse). 将WebService应用程序部署到Eclipse Helios中的GlassFish(Glassfish适配器和Eclipse中安装的插件)。 Tested the deployed service through SoapUI and it works fine. 通过SoapUI测试部署的服务,它工作正常。

I deployed this web service into Tomcat7.0 as a WAR file. 我将此Web服务作为WAR文件部署到Tomcat7.0中。 Structure as: 结构如下:

WAR -> META-INF -> MANIFEST.MF
-> WEB-INF -> classes -> ...
-> wsdl -> .wsdl and .xsd
-> web.xml
-> sun-jaxws.xml

When I test the webservice through SoapUI, the response I get is an exception as: 当我通过SoapUI测试Web服务时,我得到的响应是一个例外:

<S:Envelope xmlns:S="http://schemas.xmlsoap.org/soap/envelope/">
   <S:Body>
      <S:Fault xmlns:ns3="http://www.w3.org/2003/05/soap-envelope">
        <faultcode>S:Server</faultcode>
        <faultstring>unexpected XML tag. expected: {http://localhost/fundmanagertd}addFund but found: {http://localhost/fundmanagertd}requestAddFund</faultstring>
      </S:Fault>
   </S:Body>
</S:Envelope>

I think it is working in Glassfish because Glassfish is generating all the artifacts on the fly and not accepting the ones which are already generated. 我认为它在Glassfish中有效,因为Glassfish会动态生成所有工件,而不接受已经生成的工件。 While Tomcat is taking only those which are in the deployed package. 虽然Tomcat只采用部署包中的那些。 Why I think so, because web services work in Glassfish only when sun-jaxws.xml is not provided, but when it is provided I am not able to see the service under "Deployed Service" section. 为什么我这么认为,因为只有在没有提供sun-jaxws.xml的情况下,Web服务才能在Glassfish中工作,但是当提供它时,我无法在“已部署的服务”部分看到该服务。 While Tomcat uses sun-jasws.xml and uses the classes I have provided and fails. 虽然Tomcat使用sun-jasws.xml并使用我提供的类并失败。 I don't know why this is happening. 我不知道为什么会这样。 Any direction from here would be much appreciated. 从这里的任何方向将非常感激。

WSDL I am using: 我使用的WSDL:

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<definitions targetNamespace="http://localhost/fundmanagertd" name="FundManagerTDService" xmlns="http://schemas.xmlsoap.org/wsdl/" xmlns:tns="http://localhost/fundmanagertd" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/">
  <types>
    <xsd:schema>
      <xsd:import namespace="http://localhost/fundmanagertd" schemaLocation="FundManagerTDService_schema1.xsd"/>
    </xsd:schema>
  </types>
  <message name="addFund">
    <part name="parameters" element="tns:requestAddFund"/>
  </message>
  <message name="addFundResponse">
    <part name="parameters" element="tns:responseAddFund"/>
  </message>
  <portType name="Fund">
    <operation name="addFund">
      <input message="tns:addFund"/>
      <output message="tns:addFundResponse"/>
    </operation>
  </portType>
  <binding name="FundPortBinding" type="tns:Fund">
    <soap:binding transport="http://schemas.xmlsoap.org/soap/http" style="document"/>
    <operation name="addFund">
      <soap:operation soapAction="urn:Add"/>
      <input>
        <soap:body use="literal"/>
      </input>
      <output>
        <soap:body use="literal"/>
      </output>
    </operation>
  </binding>
  <service name="FundManagerTDService">
    <port name="FundPort" binding="tns:FundPortBinding">
      <soap:address location="REPLACE_WITH_ACTUAL_URL"/>
    </port>
  </service>
</definitions>

FundManagerTDService_schema1.xsd FundManagerTDService_schema1.xsd

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<xs:schema version="1.0" targetNamespace="http://localhost/fundmanagertd" xmlns:tns="http://localhost/fundmanagertd" xmlns:xs="http://www.w3.org/2001/XMLSchema">

  <xs:element name="requestAddFund" type="tns:requestAddFund"/>

  <xs:element name="responseAddFund" type="tns:responseAddFund"/>

  <xs:complexType name="fund">
    <xs:sequence>
      <xs:element name="annuity" type="tns:annuityType" minOccurs="0"/>
      <xs:element name="duration" type="xs:int"/>
      <xs:element name="endDate" type="xs:dateTime" minOccurs="0"/>
      <xs:element name="id" type="xs:long"/>
      <xs:element name="name" type="xs:string" minOccurs="0"/>
      <xs:element name="premium" type="xs:float"/>
      <xs:element name="startDate" type="xs:dateTime" minOccurs="0"/>
      <xs:element name="type" type="tns:investmentType" minOccurs="0"/>
      <xs:element name="value" type="xs:float"/>
    </xs:sequence>
  </xs:complexType>

  <xs:complexType name="requestAddFund">
    <xs:sequence>
      <xs:element name="arg0" type="tns:fund" minOccurs="0"/>
      <xs:element name="arg1" type="xs:string" minOccurs="0"/>
    </xs:sequence>
  </xs:complexType>

  <xs:complexType name="responseAddFund">
    <xs:sequence>
      <xs:element name="return" type="xs:long"/>
    </xs:sequence>
  </xs:complexType>

  <xs:simpleType name="annuityType">
    <xs:restriction base="xs:string">
      <xs:enumeration value="MONTHLY"/>
    </xs:restriction>
  </xs:simpleType>

  <xs:simpleType name="investmentType">
    <xs:restriction base="xs:string">
      <xs:enumeration value="MF"/>
    </xs:restriction>
  </xs:simpleType>
</xs:schema>

SoapUI is generating request automatically and it is: SoapUI自动生成请求,它是:

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:fun="http://localhost/fundmanagertd">
   <soapenv:Header/>
   <soapenv:Body>
      <fun:requestAddFund>
         <!--Optional:-->
         <arg0>
            <!--Optional:-->
            <annuity>?</annuity>
            <duration>?</duration>
            <!--Optional:-->
            <endDate>?</endDate>
            <id>?</id>
            <!--Optional:-->
            <name>?</name>
            <premium>?</premium>
            <!--Optional:-->
            <startDate>?</startDate>
            <!--Optional:-->
            <type>?</type>
            <value>?</value>
         </arg0>
         <!--Optional:-->
         <arg1>?</arg1>
      </fun:requestAddFund>
   </soapenv:Body>
</soapenv:Envelope>

Also, I have tried creating a static client to access my web service and I get SOAPFaultException with "unexpected XML tag message..." 此外,我尝试创建一个静态客户端来访问我的Web服务,我得到SOAPFaultException“带有意外的XML标记消息......”

Also, adding sun-jaxws.xml for reference: 另外,添加sun-jaxws.xml以供参考:

<?xml version="1.0" encoding="UTF-8"?>
<endpoints
  xmlns="http://java.sun.com/xml/ns/jax-ws/ri/runtime"
  version="2.0">
  <endpoint
      name="fundmanagertdservice"
      implementation="com.investment.webservice.impl.FundManagerService"
      url-pattern="/fundmanagertdsvr"
      wsdl="WEB-INF/wsdl/FundManagerTDService.wsdl"/>
</endpoints>

Thanks, 谢谢,

I think that the first element in the SOAP request Body needs to be the operations that you are calling. 我认为SOAP请求Body中的第一个元素需要是您正在调用的操作。 This means that the auto-generated XML needs to be changed. 这意味着需要更改自动生成的XML。 This is exactly what the error are saying: 这正是错误所说的:

...expected: ...预期:

...addFund - method name - but found: ... addFund - 方法名称 - 但发现:

...requestAddFund - data type name ... requestAddFund - 数据类型名称

暂无
暂无

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

相关问题 Web应用程序在带有Glassfish 4.1的Eclipse中可以正常工作,但在部署到Tomcat 9时不能正常工作 - Web app works fine in Eclipse with Glassfish 4.1 but not when deployed to Tomcat 9 SOAP 调用在 websphere 上部署时失败,但在 tomcat 上工作正常 - SOAP call fails when deployed on websphere but works fine on tomcat Hibernate / JPA在Eclipse中工作正常,部署时抛出SchemaManagementException - Hibernate/JPA works fine in Eclipse, throws a SchemaManagementException when deployed 雄猫 在Eclipse中工作,但在部署时不工作 - Tomcat. Works in Eclipse, but does not work when deployed 网站在本地工作,但是在Tomcat服务器上部署时,它不再找到Servlet。 - Website works locally, but when deployed on Tomcat server it no longer finds Servlets Spring Boot应用程序可以独立运行,但是在Tomcat中部署时找不到类 - Spring Boot application works as standalone but class not found when deployed in Tomcat 部署在Tomcat上的Spring Boot Rest API可以提供404,但可以独立运行 - Spring Boot Rest API Deployed on Tomcat gives 404 but works Stand-alone all fine Eclipse服务器(tomcat)在启动时找不到servlet,尽管在部署项目时本机tomcat运行良好 - eclipse server(tomcat) could not find servlet on startup, although native tomcat runs fine when project is deployed 当本地一切正常时,Spring Boot Security 会导致应用程序在部署到 GAE 时关闭 - Spring Boot Security causes application to shutdown when deployed to GAE when locally everything works fine 为什么当我放入.jsp但使用.html时Tomcat无法正常工作? - Why Tomcat works fine when I put a .jsp but with a .html doesn't works?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM