wsimport generuje puste obiekty

0

To jest moje SOAP api

package api;

import javax.jws.WebMethod;
import javax.jws.WebService;
import javax.jws.soap.SOAPBinding;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;
import java.util.Random;

@WebService
@SOAPBinding(style = SOAPBinding.Style.DOCUMENT)
@XmlRootElement
public class RandServiceImpl {
    private static final int maxR=100;
    @WebMethod(operationName = "next1")
    public int next1() { return new Random().nextInt();}
    @WebMethod(operationName = "nextN")
    public int[] nextN(final int n) {
        final int k = (n > maxR) ? maxR : Math.abs(n);
        int[ ] rands = new  int[k];
        Random r = new Random();
        for (int i = 0; i < k; i++) rands[i] = r.nextInt();
        return rands;
    }
}

potem generuje klienta z wsdl za pomocą wsimport
wsimport -Xnocompile -verbose -d generated -extension http://localhost:8080/soap/RandServiceImpl?wsdl
Ale generuje mi to np pusty obiekt Next1, albo NextN, w ktorym nie ma sladu po operacji generowania losowych liczb, wiec nie moge korzystac z takiego klienta. Wie ktos jak to naprawic?

0

MASM0015: Class [ com.sun.xml.ws.assembler.jaxws.HandlerTubeFactory ] does not implement [ com.sun.xml.internal.ws.assembler.dev.TubeFactory ] interface

0

ok, rozwiazalam ten problem.Jednak pusty obiekt to nie jest error, klient wyglada tak

import generated.RandServiceImpl;
import generated.RandServiceImplService;

import java.util.List;

public class RandClient {
    public static void main(String[] args) {
        RandServiceImplService service=new RandServiceImplService();
        Thread.currentThread().setContextClassLoader(RandServiceImplService.class.getClassLoader());
        RandServiceImpl port=service.getRandServiceImplPort();
        System.out.println(port.next1());
        List<Integer> nums=port.nextN(1000);
        for(Integer num:nums) System.out.println(num);
    }
}

Obiekt posiadajacy oryginalny metody otrzymuje sie w ten sposob

    @WebEndpoint(name = "RandServiceImplPort")
    public RandServiceImpl getRandServiceImplPort() {
        return super.getPort(new QName("http://api/", "RandServiceImplPort"), RandServiceImpl.class);
    }

czyli pewnie zczytuje z sieci. A ten blad wyzej wyskiwaly przy wywolaniu RandServiceImpl port=service.getRandServiceImplPort(); jednak nie wystepuje po dodaniu zaleznosci apache cxf:

    <dependency>
        <groupId>org.apache.cxf</groupId>
        <artifactId>cxf-rt-frontend-jaxws</artifactId>
        <version>3.4.0</version>
    </dependency>
    <dependency>
        <groupId>org.apache.cxf</groupId>
        <artifactId>cxf-rt-transports-http</artifactId>
        <version>3.4.0</version>
    </dependency>
    <!-- Jetty is needed if you're are not using the CXFServlet -->
    <dependency>
        <groupId>org.apache.cxf</groupId>
        <artifactId>cxf-rt-transports-http-jetty</artifactId>
        <version>3.4.0</version>
        <scope>test</scope>
    </dependency>

0

Obawiam się, że musialabys się cofnąć w czasie o jakieś 10 lat, żeby uzyskać odpowiedź xd

1 użytkowników online, w tym zalogowanych: 0, gości: 1