SOAPFaultException when deployed to Tomcat but works fine in GlassFish

Friends, I tried a lot and read a lot of forums but couldn't figure out why this problem fits.
I created a Jax-WS WebService using the first contract approach. Created the WSDL and XSD and then used the wsimport tool to generate the rest of the artifacts, provided the implementation for SEI.

Deployed WebService for GlassFish in Eclipse Helios (Glassfish adapter and plugin installed in Eclipse). Tested the deployed service via SoapUI and it works fine.

I have deployed this web service to Tomcat7.0 as a WAR file. Structure like:

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

When I test a web service through SoapUI, the response I get is an exception:

<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 works in Glassfish because Glassfish generates all artifacts on the fly and doesn't accept those that are already created. Although Tomcat only accepts those in the deployed package. Why I think so is because web services only run in Glassfish when sun-jaxws.xml is not provided, but when it is provided I cannot see the service under Deployed Service. Although Tomcat uses sun-jasws.xml and uses the classes I provided and fails. I don't know why this is happening. Any direction from here would be much appreciated.

WSDL I am using:

<?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

<?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 generates a request automatically and it:

<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 tried to create a static client to access my web service and I get a SOAPFaultException with "Unexpected XML tag message ..."

Also, adding sun-jaxws.xml for reference:

<?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>

      

Thank,

+3


source to share


1 answer


I think the first element in the SOAP Body request should be the operations you are calling. This means that the automatically generated XML needs to be modified. This is exactly what the error says:



... expected:

... addFund - method name - but found:

... requestAddFund is the name of the data type

0


source







All Articles