本文介绍了来自JAVA中SOAP生成的客户端的InaccessibleWSDLException错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们正在与服务提供商的wsdl合作,由于安全原因这是不可发现的,它们为我们提供了一堆文件,包括wsdl,xsd等。我们需要访问提供商的api。出于这些原因,我们做了以下这些事情:

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. 我们使用netbean 8.0格式桌面位置(本地)生成了一个Web服务客户端文件)

  2. 使用生成的客户端代码,我们使用以下代码调用api



URL url = new URL("http://serverip:port/payment/services/MgrService");    
MgrService svc = new MgrService(url);          
Response response = svc.getMgrServicePort().apiRequest(request);


但获得这些异常

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)

通过Wireshark,我们注意到它正在调用 get方法没有肥皂体,它应该只调用 post方法。我们使用soapUI测试了api,服务还可以。我们也使用原始xml soap请求获得成功响应。

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.

是否可以与生成的客户端一起使用 JAX-WS和当WSDL不可发现时,Spring WS ?或者它只适用于 JAX-WS 的wsdl文件。
如果是这样,那么我们需要编辑wsdl吗?或其他一些方法

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

推荐答案

经过一番研究,我发现了这些!

After few research, I have found these !

1)对于Spring WS,生成的客户端不起作用(就像Netbean生成的SOAP客户端一样)

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

2)这个链接帮助我消耗了很多弹簧 - WS服务使用 Spring STS

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

但在继续之前很少需要做的事情

but few things need to be done before you proceed

a)修复maven -jaxb2-plugin version to lower version(0.12.1)

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

b)添加一个binding.xjb文件,其中包含

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>

其他明智的xjc无法使用

other wise xjc will not work

3)复制wsdl& xsd文件到本地项目目录和pom配置将
如下(对于出于安全原因未托管wsdl的情况)

3) Copy wsdl & xsd files to local project directory and pom configuration willbe 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)不建议编辑wsdl文件

这篇关于来自JAVA中SOAP生成的客户端的InaccessibleWSDLException错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-11 08:12