Skip to content
Advertisement

javax.xml.ws.WebServiceException: close method has already been invoked

I want to implement a client for a WebService. I used IntelliJ tools to create classes from wsdl and I prepared all classes as needed to call method from the WebService interface. The problem is that every time I try to call the WebService method I receive this error:

javax.xml.ws.WebServiceException: close method has already been invoked
    at com.sun.xml.ws.client.Stub.process(Stub.java:316)
    at com.sun.xml.ws.client.sei.SEIStub.doProcess(SEIStub.java:161)
    at com.sun.xml.ws.client.sei.SyncMethodHandler.invoke(SyncMethodHandler.java:113)
    at com.sun.xml.ws.client.sei.SyncMethodHandler.invoke(SyncMethodHandler.java:93)
    at com.sun.xml.ws.client.sei.SEIStub.invoke(SEIStub.java:144)
    at com.sun.proxy.$Proxy163.test(Unknown Source)
    at com.webapp.svc.ws.client.omscentraldatasending.OmsCentralDataSendingWsClient.test(OmsCentralDataSendingWsClient.java:58)

I have a mock running on SoapUI, I sent a request from SoapUI and it’s working.

Testing the WebService starts by pressing a button in a web page. This is how I initialize my beans in the context:

<bean id="omsCentralDataSendingSvc" class="com.bean.omscentraldatasending.OmsCentralDataSendingSvc">
    <constructor-arg value="classpath:/META-INF/wsdl/omscentraldatasending/OmsCentralDataSendingSvc.wsdl"/>
</bean>

<bean id="omsCentralDataSendingTest" class="com.webapp.web.adm.omscentraldatasendingtest.OmsCentralDataSendingTest" scope="request">
    <property name="omsCentralDataSendingClient">
        <bean class="com.webapp.svc.ws.client.omscentraldatasending.OmsCentralDataSendingWsClient" init-method="init">
            <property name="webServicePort">
                <bean factory-bean="omsCentralDataSendingSvc" factory-method="getOmsCentralDataSendingEndpoint" />
            </property>
            <property name="endpointAddress" value="http://localhost:9520/OmsCentralDataSendingSvc/"/>
        </bean>
    </property>
</bean>

I realised that com.sun.xml.ws.client.Stub#close method is called at some point, which is why the error occurs later, but I don’t know why the close method is being called. If you need any additional info please let me know.

Advertisement

Answer

Apparently the problem was in initializing beans. I moved the nested bean and made it a top level and it’s working now.

<bean id="omsCentralDataSendingSvc" class="com.bean.omscentraldatasending.OmsCentralDataSendingSvc">
    <constructor-arg value="classpath:/META-INF/wsdl/omscentraldatasending/OmsCentralDataSendingSvc.wsdl"/>
</bean>

<bean id="newBean" class="com.webapp.svc.ws.client.omscentraldatasending.OmsCentralDataSendingWsClient" init-method="init">
    <property name="webServicePort">
        <bean factory-bean="omsCentralDataSendingSvc" factory-method="getOmsCentralDataSendingEndpoint" />
    </property>
    <property name="endpointAddress" value="http://localhost:9520/OmsCentralDataSendingSvc/"/>
</bean>

<bean id="omsCentralDataSendingTest" class="com.webapp.web.adm.omscentraldatasendingtest.OmsCentralDataSendingTest" scope="request">
    <property name="omsCentralDataSendingClient" ref="newBean">
</bean>

User contributions licensed under: CC BY-SA
8 People found this is helpful
Advertisement