SOAP service response cannot be displayed

This problem made me hold back almost two days, I really need help with this.

I used wsimport to generate code from two different .wsdl files for a Java project.

The first service works fine, but for some reason, the response from the second service cannot be tracked to the response object.

Service Maintenance:

@WebMethod(action = "[actionName]") @WebResult(name = "getSimpleCompanyInfoResponse", partName = "getSimpleCompanyInfoResponse") public GetSimpleCompanyInfoResponse getSimpleCompanyInfo( @WebParam(name = "getSimpleCompanyInfoRequest", partName = "getSimpleCompanyInfoRequest") GetSimpleCompanyInfoRequest getSimpleCompanyInfoRequest); 

POJO answer:

 @XmlAccessorType(XmlAccessType.FIELD) @XmlType(name = "getSimpleCompanyInfoResponse", propOrder = { //variables }) public class GetSimpleCompanyInfoResponse { //variables } 

XML response:

 <SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns1="[namespaceUri]" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> <SOAP-ENV:Body> <ns1:getSimpleCompanyInfoResponse> <getSimpleCompanyInfoResponse> //variables </getSimpleCompanyInfoResponse> </ns1:getSimpleCompanyInfoResponse> </SOAP-ENV:Body> </SOAP-ENV:Envelope> 

NOT working service:

 @WebMethod(operationName = "PersonnelInfo", action = "[actionName]") @WebResult(name = "PersonnelInfoResponse", partName = "PersonnelInfoResponse") public PersonnelInfoResponse personnelInfo( @WebParam(name = "PersonnelInfoRequest", partName = "PersonnelInfoRequest") PersonnelInfoRequest personnelInfoRequest); 

POJO answer:

 @XmlAccessorType(XmlAccessType.FIELD) @XmlType(name = "PersonnelInfoResponse", propOrder = { //variables }) public class PersonnelInfoResponse { //variables } 

XML response:

 <SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns1="[namespaceUri]" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> <SOAP-ENV:Body> <ns1:PersonnelInfoResponse> //variables </ns1:PersonnelInfoResponse> </SOAP-ENV:Body> </SOAP-ENV:Envelope> 

Using -Dcom.sun.xml.internal.ws.transport.http.client.HttpTransportPipe.dump = true or monitoring using Wireshark, I can see the Response envelope from the second service passing through the fine and non-marshalling does not cause any exceptions, but in end of PersonnelInfoResponse is null.

The only difference I see is that the second service payload in XML does not contain an external element, which seems to be the problem. However, I do not know how to β€œfix” it so that it does not look for an external element.

If something is unclear or missing, let me know and I will try to provide you with all the information.

EDIT:

No, I, unfortunately, have no control over the service itself, I only have .wsdl and .xsd.

I call the service as follows:

 ReportsControllerPortType port = new ReportsControllerService().getReportsControllerPort(); PersonnelInfoRequest request = new PersonnelInfoRequest(); //fill the required fields in the request, username, password, etc. PersonnelInfoResponse response = port.personnelInfo(request); 

Client-side service supports (ReportsControllerService and ReportsControllerPortType) are also automatically generated by wsimport according to .wsdl and .xsd.

EDIT 2:

Deleting the operation name does not work, the service does not initialize. The following are definitions from .wsdl-s:

Service Maintenance:

 <wsdl:message name="getSimpleCompanyInfoRequest"> <wsdl:part name="getSimpleCompanyInfoRequest" type="tns:getSimpleCompanyInfoRequest" /> </wsdl:message> <wsdl:message name="getSimpleCompanyInfoResponse"> <wsdl:part name="getSimpleCompanyInfoResponse" type="tns:getSimpleCompanyInfoResponse" /> </wsdl:message> <wsdl:portType name="MonitoringControllerPortType"> <wsdl:operation name="getSimpleCompanyInfo"> <wsdl:input message="tns:getSimpleCompanyInfoRequest" /> <wsdl:output message="tns:getSimpleCompanyInfoResponse" /> </wsdl:operation> </wsdl:portType> <wsdl:binding name="MonitoringControllerBinding" type="tns:MonitoringControllerPortType"> <soap:binding style="rpc" transport="http://schemas.xmlsoap.org/soap/http" /> <wsdl:operation name="getSimpleCompanyInfo"> <soap:operation soapAction="[domain]/#getSimpleCompanyInfo" style="rpc" /> <wsdl:input> <soap:body use="literal" namespace="[namespaceUri]" /> </wsdl:input> <wsdl:output> <soap:body use="literal" namespace="[namespaceUri]" /> </wsdl:output> </wsdl:operation> </wsdl:binding> <wsdl:service name="MonitoringControllerService"> <wsdl:port name="MonitoringControllerPort" binding="tns:MonitoringControllerBinding"> <soap:address location="[serviceUri]" /> </wsdl:port> </wsdl:service> 

Not working service:

 <wsdl:message name="PersonnelInfoRequest"> <wsdl:part name="PersonnelInfoRequest" type="tns:PersonnelInfoRequest" /> </wsdl:message> <wsdl:message name="PersonnelInfoResponse"> <wsdl:part name="PersonnelInfoResponse" type="tns:PersonnelInfoResponse" /> </wsdl:message> <wsdl:portType name="ReportsControllerPortType"> <wsdl:operation name="PersonnelInfo"> <wsdl:input message="tns:PersonnelInfoRequest" /> <wsdl:output message="tns:PersonnelInfoResponse" /> </wsdl:operation> </wsdl:portType> <wsdl:binding name="ReportsControllerBinding" type="tns:ReportsControllerPortType"> <soap:binding style="rpc" transport="http://schemas.xmlsoap.org/soap/http" /> <wsdl:operation name="PersonnelInfo"> <soap:operation soapAction="[domain]/#PersonnelInfo" style="rpc" /> <wsdl:input> <soap:body use="literal" namespace="[namespaceUri]" /> </wsdl:input> <wsdl:output> <soap:body use="literal" namespace="[namespaceUri]" /> </wsdl:output> </wsdl:operation> </wsdl:binding> <wsdl:service name="ReportsControllerService"> <wsdl:port name="ReportsControllerPort" binding="tns:ReportsControllerBinding"> <soap:address location="[serviceUri]" /> </wsdl:port> </wsdl:service> 

EDIT 3:

The ReportControllerService and MonitoringControllerService service extends javax.xml.ws.Service and contains the location and namespace definitions .wsdl. The service class returns a PortType object, as you can see:

 /** * This class was generated by the JAX-WS RI. JAX-WS RI 2.2.9-b130926.1035 Generated source version: 2.2 */ @WebServiceClient(name = "ReportsControllerService", targetNamespace = "[namespaceUri]", wsdlLocation = "[wsdlUri]") public class ReportsControllerService extends Service { @WebEndpoint(name = "ReportsControllerPort") public ReportsControllerPortType getReportsControllerPort() { return super.getPort(new QName("[namespaceUri]", "ReportsControllerPort"), ReportsControllerPortType.class); } } 

ReportControllerPortType is an interface that contains methods for each endpoint of an operation that exists in a service

 /** * This class was generated by the JAX-WS RI. JAX-WS RI 2.2.9-b130926.1035 Generated source version: 2.2 */ @WebService(name = "ReportsControllerPortType", targetNamespace = "[namespaceUri]") @SOAPBinding(style = SOAPBinding.Style.RPC) @XmlSeeAlso({ObjectFactory.class}) public interface ReportsControllerPortType { @WebMethod(operationName = "PersonnelInfo", action = "[actionName]") @WebResult(name = "PersonnelInfoResponse", partName = "PersonnelInfoResponse") public PersonnelInfoResponse personnelInfo( @WebParam(name = "PersonnelInfoRequest", partName = "PersonnelInfoRequest") PersonnelInfoRequest personnelInfoRequest); } } 

The fact is that all these classes are automatically generated by JAX-WS (as you can see from the comments) based on the .wsdl scheme. The implementation is abstracted somewhere inside the JDK, and I have no control over that either. Yes, I can refactor the code, so I circumvented JAX-WS, but as I understand it, this should be the standard way to use .wsdl-based SOAP services.

The project uses Spring as the base structure, and I have already confirmed that both services will work when I use Spring -WS instead, so that I can refactor, but I want to understand why this method does not work.

+6
source share
2 answers

I believe that perhaps I found out why your web service is behaving badly. According to the specification, the RPC web service must fulfill the following criteria in relation to soap (i.e. the @SOAPBinding annotation that you are there)

  • A style of RPC : check

  • A use of LITERAL : check

  • A parameterStyle of WRAPPED : from the description you WRAPPED , it turned out that WRAPPED is not here because you get a bare PersonnelInfoResponse (and maybe sending a bare PersonnelInfoRequest ) without any wrapper indicates that the service itself is broken.

Excerpt from the JAX-WS specification :

Using the RPC style requires using the WRAPPED parameter WRAPPED . Deviations from this is a mistake

+1
source

There is one obvious difference between your 2 calls:

You should try to remove operationName = "PersonnelInfo" from your second call, which is not in the first worker.

0
source

Source: https://habr.com/ru/post/986667/


All Articles