The service class does not meet one or more of the JAX-RPC 1.1 specification requirements and may not deploy or function correctly

I am new to Java Webservices, I am currently trying to create simple SOAP based web services but the problem comes up while building it.

Here is my webservice class:

@WebService
public class Teams {
    private TeamsUtility utils;

    public Teams() { 
       utils = new TeamsUtility(); 
       utils.make_test_teams();
    }

    @WebMethod
    public Team getTeam(String name) { return utils.getTeam(name); }

    @WebMethod
    public List<Team> getTeams() { return utils.getTeams(); }

    @WebMethod
    public String getDummyTeams() { return "Hi"; }
}

      

As you can see, I have 3 methods. Now if I just hold getDummyTeams

and ask eclipse to create a WebService then I have no problem. But when I tried to add the remaining 2 methods public Team getTeam(String name)

and public List<Team> getTeams()

then when creating the webservice I get an error like:

The "helloservice.endpoint.Teams" service class does not meet one or more of the JAX-RPC 1.1 specification requirements, and may not deploy or function correctly. The field or property "players" of the value type "helloservice.endpoint.Team" used through the "helloservice.endpoint.Teams" service class is of the "java.util.List" data type, which is not supported by the JAX-RPC 1.1 specification. Instances of the type cannot be serialized or deserialized correctly. Loss of data or a complete failure of the web service may result.

Here is my class Team

:

@XmlRootElement
public class Team implements Serializable{
    private List<Player> players;
    private String name;

    public Team() {
    }

    public Team(String name, List<Player> players) {
        setName(name);
        setPlayers(players);
    }
// Setter & Getter methods
}

      

Could you please help me how can I fix this problem? I want to use java.util.List

. Are there any settings I should change in eclipse for using collections when building SOAP based web services?

+3


source to share


5 answers


This is not a direct answer to the question. But nevertheless, I would like to point out that you can not use JAX-RPC at all.

First of all, JAX-RPC is an old API that has been superseded by JAX-WS.

Reasons why you might want to stay with JAX-RPC 1.1 : ... If you want to send SOAP encoded messages or create RPC / encoded WSDL style messages.

And that brings us to the question "What is an encoded WSDL style ?"

The WSDL file contains the definition of the methods for your web service. And there are 4 ways / styles to define these methods:

  • RPC / encoded
  • RPC / literal
  • Document / encoded
  • Document / literal

Each style has advantages and disadvantages. The most important of these is the following note:



While this is legal WSDL, RPC / encoded is not WS-I compliant.

WS-I stands for "webservice compatibility". So as the quote progresses, although JAX-RPC does support RPC / WSDL encoded files, that doesn't mean it's compatible with other RPC / encoded technologies (like web services written in PHP). JAX-RPC web services between Java and PHP may run at first, but may sometimes break in certain cases. So the lesson: avoid WSDL RPC / encoded files. And that's why JAX-WS doesn't support them.

Unfortunately, sometimes you have no choice (for example, another company provides a web service). If it's an RPC / encoded WSDL file, then you won't be able to use JAX-WS. If the hosted web service is also written in Java, you can take a chance with JAX-RPC. If it is written in some other language, I would not risk it . When this happens, you are better off writing a custom handler. (You can safely use JAXB (Java Xml Binding) to perform (un) sorting (converting from / to xml) using annotations, as with JAX-WS web services.)

But how do you know if this is a WSDL file RPC / encoded? You just open it in a text editor and look for the anchor tag. The next example is an RPC / literal style WSDL file. This way you can use JAX-WS with this webservice.

<binding name="MyService" type="tns:MyService">
  <soap:binding transport="http://schemas.xmlsoap.org/soap/http" style="rpc"/>
  <operation name="method">
    <soap:operation soapAction=""/>
    <input>
      <soap:body use="literal" .../>
    </input>
    <output>
      <soap:body use="literal" .../>
    </output>
  </operation>
</binding>

      

When you define your own web service, you can choose the WSDL style by annotating your class with @SOAPBinding(style=Style.RPC, use=Use.LITERAL)

.

Source of confusion: both JAX-RPC and JAX-WS use SOAP. There is also called XML-RPC

, which is an old standard (before SOAP). But JAX-RPC doesn't use XML-RPC

.
On the other hand, SOAP is sometimes referred to as " RPC- based XML ".

+4


source


I think JAX RPC 1.1 does not support List as a datatype for bean classes. Use Array instead. you can see this answer for a similar problem



0


source


The main reason collection classes are not standardized for use in Java Web Services is because they are typed collections. In the absence of significant additional input from the user, it is not possible to map a Java collection with a well-defined schema and clear runtime rules for serializing and deserializing collection items.

Use Java arrays instead of collections to represent sequences of elements in WSDL. Java arrays are strongly typed and, as a result, map to and from a strongly typed Schema, providing compliant WSDL and SOAP traffic with clear deserialization and serialization rules to and from Java. See the link.

0


source


The JAX-RPC 1.1 specification provides something called pluggable serializers and deserializers to support collection classes.

0


source


The JAX-RPC 1.1 specification does not specify a clear mapping between the java.util.List object and XML. Since you are returning type java.util.List.

change your method like

public Team[] getTeams() { return utils.getTeams(); }

      

And your implementation getTeams()

should match that.

0


source







All Articles