InaccessibleWSDLException error from SOAP generate

2019-03-01 04:33发布

We are working with service provider's wsdl which is not discoverable due to security reason and they provide us a bunch of files including wsdl ,xsd etc.We need to access the provider's api. For these reason we have done these following things:

  1. We have generated a web service client using netbean 8.0 form desktop location (Local File )
  2. Using generated client code we have called the api using these following code
URL url = new URL("http://serverip:port/payment/services/MgrService");    
MgrService svc = new MgrService(url);          
Response response = svc.getMgrServicePort().apiRequest(request);

but getting these exception

com.sun.xml.internal.ws.wsdl.parser.InaccessibleWSDLException: 2 counts of InaccessibleWSDLException.

java.io.IOException: Server returned HTTP response code: 500 for URL: http://serviceip:port/payment/services/MgrService
java.io.IOException: Server returned HTTP response code: 500 for URL: http://serviceip:port/payment/services/MgrService?wsdl

    at com.sun.xml.internal.ws.wsdl.parser.RuntimeWSDLParser.tryWithMex(RuntimeWSDLParser.java:260)
    at com.sun.xml.internal.ws.wsdl.parser.RuntimeWSDLParser.parse(RuntimeWSDLParser.java:231)
    at com.sun.xml.internal.ws.wsdl.parser.RuntimeWSDLParser.parse(RuntimeWSDLParser.java:194)
    at com.sun.xml.internal.ws.wsdl.parser.RuntimeWSDLParser.parse(RuntimeWSDLParser.java:163)
    at com.sun.xml.internal.ws.client.WSServiceDelegate.parseWSDL(WSServiceDelegate.java:348)
    at com.sun.xml.internal.ws.client.WSServiceDelegate.<init>(WSServiceDelegate.java:306)
    at com.sun.xml.internal.ws.client.WSServiceDelegate.<init>(WSServiceDelegate.java:215)
    at com.sun.xml.internal.ws.client.WSServiceDelegate.<init>(WSServiceDelegate.java:196)
    at com.sun.xml.internal.ws.client.WSServiceDelegate.<init>(WSServiceDelegate.java:192)
    at com.sun.xml.internal.ws.spi.ProviderImpl.createServiceDelegate(ProviderImpl.java:104)
    at javax.xml.ws.Service.<init>(Service.java:77)

By Wireshark, we have noticed that it is calling a get method with no soap body, where it should call only post method . We have tested the api using soapUI , service is ok . We also getting successful response using raw xml soap request.

Is it possible to work with generated client both for JAX-WS and Spring WS when WSDL is not discoverable ? or it only work with JAX-WS's wsdl file. If so then do we need to edit wsdl? or some other approach

1条回答
Fickle 薄情
2楼-- · 2019-03-01 05:07

After few research, I have found these !

1)For Spring WS, generated client is not working (As like Netbean Generated SOAP client)

2) This link help me a lot to consume a Spring-WS service using Spring STS Consuming a SOAP web service

but few things need to be done before you proceed

a) fix maven-jaxb2-plugin version to lower version (0.12.1)

b) add a binding.xjb file with these contains

<?xml version="1.0"?>
<jxb:bindings version="1.0" xmlns:jxb="http://java.sun.com/xml/ns/jaxb"
              xmlns:xjc= "http://java.sun.com/xml/ns/jaxb/xjc"
              jxb:extensionBindingPrefixes="xjc" xmlns:xs="http://www.w3.org/2001/XMLSchema">
    <jxb:bindings>
        <jxb:globalBindings>
            <xjc:simple/>
        </jxb:globalBindings>
    </jxb:bindings>
</jxb:bindings>

other wise xjc will not work

3) Copy wsdl & xsd files to local project directory and pom configuration will be as follows (for scenario where wsdl is not hosted for security reason)

<configuration>
                    <schemaDirectory>${project.basedir}/src/main/resources/wsdl</schemaDirectory>
                    <schemaIncludes>
                        <include>*.wsdl</include>
                    </schemaIncludes>
                </configuration>

3)It is not recommended to edit the wsdl file

查看更多
登录 后发表回答