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

13,370

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

First of all, JAX-RPC is an old API, which has been replaced with JAX-WS.

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

And that leads us to the question "what is an RPC-encoded WSDL style?"

The WSDL file contains the definition of the methods of your webservice. 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 one is the following remark:

Although it is legal WSDL, RPC/encoded is not WS-I compliant.

WS-I stands for "webservice interoperability". So, as the quote clarifies, even though JAX-RPC supports RPC/encoded WSDL files, that doesn't mean it's compatible with other RPC/encoded technologies (e.g. webservices written in PHP). JAX-RPC webservices between Java and PHP may seem to work at first, but will sometimes break in specific cases. So the lesson is: avoid RPC/encoded WSDL files. And that's exactly why JAX-WS doesn't support them.

Unfortunately, sometimes you don't have a choice (e.g. another company provides the webservice) If it's a RPC/encoded WSDL file, then you won't be able to use JAX-WS. If the hosted webservice is also written in Java, then you could risk using JAX-RPC. If it's written in some other language, then I wouldn't take the risk. You're better of writing a custom handler when that happens. (You can still safely use JAXB (Java Xml Binding) to perform the (un)marshalling (conversion from/to xml) using annotations, just like with JAX-WS webservices.)

But how do you know if it's an RPC/encoded WSDL file? You just open it in a text editor, and look for the binding tag. The following example is an RPC/literal style WSDL file. So 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 webservice, you can choose the WSDL style by annotating your class with @SOAPBinding(style=Style.RPC, use=Use.LITERAL).

A source of confusion: both JAX-RPC and JAX-WS use SOAP. There's also a thing called XML-RPC which is an old standard (before SOAP). But JAX-RPC does not use XML-RPC. On the other hand, SOAP is sometimes called "XML based RPC".

Share:
13,370
learner
Author by

learner

Updated on June 28, 2022

Comments

  • learner
    learner almost 2 years

    I am new to Java Webservices, currently I am trying to create a simple SOAP based web-services but getting issue in creating 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 here. Now if I just keep getDummyTeams and ask eclipse to create a WebService, then I have no issues. But when I tried to add remaining 2 methods public Team getTeam(String name) & public List<Team> getTeams() then while creating webservice I am getting error as :

    The service class "helloservice.endpoint.Teams" does not comply to one or more requirements of the JAX-RPC 1.1 specification, and may not deploy or function correctly. The field or property "players" on the value type "helloservice.endpoint.Team" used via the service class "helloservice.endpoint.Teams" has a data type, "java.util.List", that is not supported by the JAX-RPC 1.1 specification. Instances of the type may not serialize or deserialize correctly. Loss of data or complete failure of the Web service may result.

    Here is my Team class:

    @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
    }
    

    Can you please help me how do I fix this issue? I want to use java.util.List. Is there any settings I have to change in eclipse to use collections while creating SOAP based web-services?

  • learner
    learner almost 9 years
    I want to use List in my program, I guess there should be some setting which I am missing to fix this issue for creating webservice. Please suggest how to fix the issue even when I use List.
  • Amit.rk3
    Amit.rk3 almost 9 years
    From the error message, It seems you are using JAX RPC 1.1. You might want to check this link which explains supported data types for this version. You can check from section 4.2
  • learner
    learner almost 9 years
    yes I agree, i am using eclipse to develop this, how to fix the issue without changing data types? because collections are better than ararys, and there should be some solution to this, may be not using JAX RPC but I want to know how to do that.
  • learner
    learner almost 9 years
    Thanks for responding, can you please tell how to fix the issue, can you provide some link where the steps are given to fix this issue?
  • Amol Binwade
    Amol Binwade almost 9 years