简体   繁体   English

WSDL 网络服务 BasicAuthenticationResolver

[英]WSDL webservice BasicAuthenticationResolver

I am using soa-model-core for getting defination from wsdl wenservice url.我正在使用 soa-model-core 从 wsdl wenservice url 获取定义。 Without authentication WSDLParser is working fine.没有身份验证 WSDLParser 工作正常。 But if url contains with Basic Auth it is throwing 401 error.但如果 url 包含 Basic Auth,则会引发 401 错误。

I tried with BasicAuthenticationResolver also not working following error i am getting error.我尝试使用 BasicAuthenticationResolver 也无法正常工作以下错误我收到错误。 I need Defination from webservice is their any alter native way.我需要来自 webservice 的定义是他们的任何替代方式。 By using Httpclient i am getting response in string.通过使用 Httpclient 我得到了字符串的响应。 From String any way to convert to Defination for Binding.从 String 以任何方式转换为 Defination for Binding。

import java.io.IOException;
import com.predic8.wsdl.Definitions;
import com.predic8.wsdl.WSDLParser;
import com.predic8.xml.util.BasicAuthenticationResolver;

public class Test {

    public static void main(String[] args) throws ClientProtocolException, IOException {
        String str="http://localhost:7005/OrderManagement/wsapi?WSDL";
        WSDLParser ws=new WSDLParser();
        BasicAuthenticationResolver bs=new BasicAuthenticationResolver();
        bs.setBaseDir("http");
        bs.setUsername("osm");
        bs.setPassword("osmadmin1");
        ws.setResourceResolver(bs);
        Definitions df=ws.parse(str);
        System.out.println(df.toString());

    }
}

ERROR:错误:

Exception in thread "main" groovy.lang.MissingMethodException: No signature of method: com.predic8.xml.util.BasicAuthenticationResolver.resolve() 
is applicable for argument types: (java.lang.String, java.lang.String) values: [http://192.168.1.105:7005/OrderManagement/wsapi?WSDL, ]
Possible solutions: resolve(java.lang.Object)
    at org.codehaus.groovy.runtime.ScriptBytecodeAdapter.unwrap(ScriptBytecodeAdapter.java:58)
    at org.codehaus.groovy.runtime.callsite.PogoMetaClassSite.call(PogoMetaClassSite.java:54)
    at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:48)
    at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:113)
    at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:133)
    at com.predic8.soamodel.AbstractParser.getResourceToken(AbstractParser.groovy:47)
    at com.predic8.soamodel.AbstractParser.this$2$getResourceToken(AbstractParser.groovy)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
    at java.lang.reflect.Method.invoke(Unknown Source)
    at org.codehaus.groovy.runtime.callsite.PogoMetaMethodSite$PogoCachedMethodSiteNoUnwrapNoCoerce.invoke(PogoMetaMethodSite.java:210)
    at org.codehaus.groovy.runtime.callsite.PogoMetaMethodSite.callCurrent(PogoMetaMethodSite.java:59)
    at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCallCurrent(CallSiteArray.java:52)
    at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callCurrent(AbstractCallSite.java:154)
    at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callCurrent(AbstractCallSite.java:166)
    at com.predic8.soamodel.AbstractParser.parse(AbstractParser.groovy:35)
    at com.predic8.wsdl.WSDLParser.super$2$parse(WSDLParser.groovy)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
    at java.lang.reflect.Method.invoke(Unknown Source)
    at org.codehaus.groovy.reflection.CachedMethod.invoke(CachedMethod.java:93)
    at groovy.lang.MetaMethod.doMethodInvoke(MetaMethod.java:325)
    at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:1215)
    at org.codehaus.groovy.runtime.ScriptBytecodeAdapter.invokeMethodOnSuperN(ScriptBytecodeAdapter.java:132)
    at com.predic8.wsdl.WSDLParser.parse(WSDLParser.groovy:24)
    at test.Test.main(Test.java:21)

the predict8 don't support basic authentication predict8 不支持基本身份验证

my solution is : for getting protected WSDL services and, saving it to the *.wsdl file.我的解决方案是:获取受保护的 WSDL 服务并将其保存到 *.wsdl 文件中。 I utilized HttpURLConnection with basic authentication https://www.baeldung.com/java-http-url-connection now I have a WSDL file and easily can use it with predict8 library我使用 HttpURLConnection 和基本身份验证https://www.baeldung.com/java-http-url-connection现在我有一个 WSDL 文件,可以轻松地将它与 predict8 库一起使用

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM