reficio / soap-ws

Java library, based on Spring-WS, that enables handling SOAP on a purely XML level
298 stars 146 forks source link

SOAP binding not recognized? #56

Closed theirish81 closed 7 years ago

theirish81 commented 7 years ago

Hello, so what I'm trying to do is browsing through a WSDL file and print all input messages.

 Wsdl wsdl = Wsdl.parse("http://www.thomas-bayer.com/axis2/services/BLZService?wsdl");
        Iterator<QName> iterator = wsdl.getBindings().iterator();
        SoapContext context = SoapContext.builder().exampleContent(false).build();
        while(iterator.hasNext()){
            QName qname = iterator.next();
            SoapBuilder builder = wsdl.getBuilder(qname,context);
            Iterator<SoapOperation> iterator2 = builder.getOperations().iterator();
            while(iterator2.hasNext()) {
                SoapOperation soapOperation = iterator2.next();
                System.out.println(builder.buildInputMessage(soapOperation,context));
                break;
            }

        }

With some WSDLs, it just works, but for some others I get:

Exception in thread "main" org.reficio.ws.SoapBuilderException: SOAP binding not recognized
    at org.reficio.ws.builder.core.SoapBuilderImpl.buildInputMessage(SoapBuilderImpl.java:115)
    at Main.main(Main.java:28)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:498)
    at com.intellij.rt.execution.application.AppMain.main(AppMain.java:140)
Caused by: org.reficio.ws.SoapBuilderException: SOAP binding not recognized
    at org.reficio.ws.legacy.SoapLegacyFacade.buildSoapMessageFromInput(SoapLegacyFacade.java:54)
    at org.reficio.ws.builder.core.SoapBuilderImpl.buildInputMessage(SoapBuilderImpl.java:113)
    ... 6 more
Caused by: org.reficio.ws.SoapBuilderException: SOAP binding not recognized
    at org.reficio.ws.legacy.SoapMessageBuilder.getSoapVersion(SoapMessageBuilder.java:380)
    at org.reficio.ws.legacy.SoapMessageBuilder.buildSoapMessageFromInput(SoapMessageBuilder.java:230)
    at org.reficio.ws.legacy.SoapLegacyFacade.buildSoapMessageFromInput(SoapLegacyFacade.java:52)
    ... 7 more

Am I doing something terribly wrong or is it a bug?

theirish81 commented 7 years ago

Now I realize I'm doing something terribly wrong, sorry for that.

milfar commented 6 years ago

Hi, How did you fix this issue?

xkcoding commented 5 years ago

Now I realize I'm doing something terribly wrong, sorry for that.

I want to print the input message, I get the same error, and how to fix this issue?

by the way, I write the code like your code:

        SoapContext context = SoapContext.builder()
                .alwaysBuildHeaders(true)
                .buildOptional(true)
                .exampleContent(true)
                .typeComments(true)
                .build();

        Wsdl wsdl = Wsdl.parse("http://www.webxml.com.cn/WebServices/WeatherWebService.asmx?wsdl");
        List<QName> bindings = wsdl.getBindings();
        for (QName binding : bindings) {
            SoapBuilder builder = wsdl.getBuilder(binding, context);
            List<SoapOperation> operations = builder.getOperations();
            for (SoapOperation operation : operations) {
                String inputMessage = builder.buildInputMessage(operation, context);

                System.out.println("[binding] = " + binding.getLocalPart() + " ,[inputMessage] = " + inputMessage);
            }
        }
xkcoding commented 5 years ago

I use this way to temporary solve this error

SoapContext context = SoapContext.builder()
        .alwaysBuildHeaders(true)
        .buildOptional(true)
        .exampleContent(false)
        .typeComments(true)
        .build();

Wsdl wsdl = Wsdl.parse("http://www.webxml.com.cn/WebServices/WeatherWebService.asmx?wsdl");
List<QName> bindings = wsdl.getBindings();
System.out.println("bindings = " + bindings);
for (QName binding : bindings) {
    SoapBuilder builder = wsdl.getBuilder(binding, context);
    List<SoapOperation> operations = builder.getOperations();
    System.out.println("operations = " + operations);
    for (SoapOperation operation : operations) {
        try {
            String inputMessage = builder.buildInputMessage(operation, context);
            System.err.println("【binding】= " + binding.getLocalPart() + "【operation】= " + operation.getOperationName() + "【inputMessage】= \n" + inputMessage);
        } catch (SoapBuilderException e) {
            // ignore
        }
    }
}