You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cxf.apache.org by Xavier López <xa...@gmail.com> on 2012/03/07 09:49:43 UTC

Consuming a webservice with over SSL redirection

Hi. I've deployed a contract-first web service using CXF.

The server into which it is deployed performs 302 redirections from http to
ssl, so any request to http://server/app/* returns an HTTP 302 error code
and redirects to https://server/app/*.

In the original WSDL there are references to XSD elements in another
namespace, so the generated WSDL (the one
http://server/app/services/MyService?wsdl provides) contains a
`<wsdl:import>` element.

If I try to invoke the WS by manually building a SOAP request in a String
and send it over an SSL socket, the WS responds correctly. I've got all
necessary certificates in my keystore.

However, when I try to build a client using CXF's wsdl2java pointing to `
https://server/app/services/MyService?wsdl`, I get the following error:

    [Fatal Error] MyService?wsdl=MyServicePortType.wsdl:1:50: White spaces
are required between publicId and systemId.

    WSDLToJava Error: org.apache.cxf.wsdl11.WSDLRuntimeException:
    Fail to create wsdl definition from :
https://server/app/services/MyService?wsdl
    Caused by : WSDLException (at /wsdl:definitions/wsdl:import):
    faultCode=PARSER_ERROR: Problem parsing '
http://server:80/app/services/MyService?wsdl=MyServicePortType.wsdl'.:
    org.xml.sax.SAXParseException: White spaces are required between
publicId and systemId.

The trace is referring to the `<wsdl:import>` statement. Its `location`
attribute is `
http://server:80/app/services/MyService?wsdl=MyServicePortType.wsdl`. My
guess is that the error is thrown because of the 302 redirection.

The original WSDL is URL-agnostic, and the service's URL is defined
relative. It is accessed through the CXF servlet.

Should I specify somewhere in the service's autogenerated classes or wsdl
that the service is to be deployed on SSL? And how could I do it?

Re: Consuming a webservice with over SSL redirection

Posted by Xavier López <xa...@gmail.com>.
Regarding this same matter, I've found that the <soap:address
location> attribute generated by CXF at deployment time turns out to
be http://myserver:80/services/MyService. All the clients I've tested
fail to make a request to the service, due to Apache redirecting this
URL to HTTPS.

I'm currently specifying the endpoint's address as relative, by means
of a Spring <jaxws:endpoint> element:

<jaxws:endpoint
    id="myServiceEndpoint"
    implementor="#implementorBean"
    address="/MyService">
</jaxws:endpoint>

Does anyone know how is this <soap:address location> attribute
generated, and how can I make it point to
https://myserver/services/MyService instead of
http://myserver:80/services/MyService?

Kind regards,
Xavier


2012/3/8 Xavier López <xa...@gmail.com>:
> It turns out the service implementation mypackage.MyServiceImpl was
> missing the javax.jws.WebService annotation.
>
> Once included with the proper serviceName, portName, targetNamespace,
> and endpointInterface attributes, the service deployed without
> <wsdl:import>. I suspect this has to do mainly with the
> targetNamespace attribute.
>
> However, external XSD's still get referenced with http addresses, like
> `. I referenced them relative in the original WSDL. The only solution
> to this for me has been inlining all XSD definitions in the original
> WSDL. Does anyone know an alternative solution so I can properly have
> schemas in an external XSD?
>
> Many thanks,
> Xavier
>
> 2012/3/7 Aki Yoshida <el...@googlemail.com>:
>> Hi Xavier,
>> Yes. I meant for the wsdl's imports. But I don't know how your wsdl is
>> built or generated. If it is automatically generated, you probably
>> can't change that import's location.
>>
>> Maybe, there might be a property you can configure to follow the
>> redirection, but I don't know. Maybe, someone else can help.
>>
>> regards, aki
>>
>> 2012/3/7 Xavier López <xa...@gmail.com>:
>>> Thanks for your response, Aki. I don't know the way, if there's any.
>>> I'd appreciate any tip on this matter.
>>>
>>> Is this actually a defect in the XML parser, unable to follow the redirect ?
>>>
>>> I forgot specifying my service's URL is defined relative to the app,
>>> in a Spring <jaxws:endpoint>, like this:
>>>
>>> <import resource="classpath:META-INF/cxf/cxf.xml"/>
>>> <import resource="classpath:META-INF/cxf/cxf-extension-soap.xml" />
>>> <import resource="classpath:META-INF/cxf/cxf-servlet.xml"/>
>>> <bean id="myServiceBean" class="mypackage.MyServiceImpl" />
>>> <jaxws:endpoint
>>>     id="myServiceEndpoint"
>>>     implementor="#myServiceBean"
>>>     address="/MyService">
>>> </jaxws:endpoint>
>>>
>>> Maybe I should investigate how is that
>>> "http://server:80/app/services/MyService?wsdl=MyServicePortType.wsdl"
>>> address made up.
>>>
>>> I'll also post a complete stack trace, just in case.
>>>
>>> D:\>wsdl2java -d src -client -impl -verbose -db xmlbeans
>>> -autoNameResolution -validate -compile -classdir classes
>>> https://server/app/services/MyService?wsdl
>>> Loading FrontEnd jaxws ...
>>> Loading DataBinding xmlbeans ...
>>> wsdl2java -d src -client -impl -verbose -db xmlbeans -autoNameResolution -valida
>>> te -compile -classdir classes https://server/app/services/MyService?wsdl
>>> wsdl2java - Apache CXF 2.3.2
>>>
>>> [Fatal Error] MyService?wsdl=MyServicePortType.wsdl:1:50: White spaces
>>> are required between publicId and systemId.
>>>
>>> WSDLToJava Error: org.apache.cxf.wsdl11.WSDLRuntimeException: Fail to
>>> create wsdl definition from :
>>> https://server/app/services/MyService?wsdl
>>> Caused by : WSDLException (at /wsdl:definitions/wsdl:import):
>>> faultCode=PARSER_ERROR: Problem parsing
>>> 'http://server:80/app/services/MyService?wsdl=MyServicePortType.wsdl'.:
>>> org.xml.sax.SAXParseException: White spaces are required between
>>> publicId and systemId.
>>>
>>> org.apache.cxf.tools.common.ToolException:
>>> org.apache.cxf.wsdl11.WSDLRuntimeException: Fail to create wsdl
>>> definition from : https://server/app/services/MyService?wsdl
>>> Caused by : WSDLException (at /wsdl:definitions/wsdl:import):
>>> faultCode=PARSER_ERROR: Problem parsing
>>> 'http://server:80/app/services/MyService?wsdl=MyServicePortType.wsdl'.:
>>> org.xml.sax.SAXParseException: White spaces are required between
>>> publicId and systemId.
>>>        at org.apache.cxf.tools.wsdlto.WSDLToJavaContainer.execute(WSDLToJavaContainer.java:288)
>>>        at org.apache.cxf.tools.common.toolspec.ToolRunner.runTool(ToolRunner.java:103)
>>>        at org.apache.cxf.tools.wsdlto.WSDLToJava.run(WSDLToJava.java:113)
>>>        at org.apache.cxf.tools.wsdlto.WSDLToJava.run(WSDLToJava.java:86)
>>>        at org.apache.cxf.tools.wsdlto.WSDLToJava.main(WSDLToJava.java:184)
>>> Caused by: org.apache.cxf.wsdl11.WSDLRuntimeException: Fail to create
>>> wsdl definition from : https://server/app/services/MyService?wsdl
>>> Caused by : WSDLException (at /wsdl:definitions/wsdl:import):
>>> faultCode=PARSER_ERROR: Problem parsing
>>> 'http://server:80/app/services/MyService?wsdl=MyServicePortType.wsdl'.:
>>> org.xml.sax.SAXParseException: White spaces are required between
>>> publicId and systemId.
>>>        at org.apache.cxf.wsdl11.WSDLDefinitionBuilder.parseWSDL(WSDLDefinitionBuilder.java:97)
>>>        at org.apache.cxf.wsdl11.WSDLDefinitionBuilder.build(WSDLDefinitionBuilder.java:69)
>>>        at org.apache.cxf.tools.wsdlto.frontend.jaxws.wsdl11.JAXWSDefinitionBuilder.build(JAXWSDefinitionBuilder.java:84)
>>>        at org.apache.cxf.tools.wsdlto.frontend.jaxws.wsdl11.JAXWSDefinitionBuilder.build(JAXWSDefinitionBuilder.java:61)
>>>        at org.apache.cxf.tools.wsdlto.WSDLToJavaContainer.processWsdl(WSDLToJavaContainer.java:170)
>>>        at org.apache.cxf.tools.wsdlto.WSDLToJavaContainer.execute(WSDLToJavaContainer.java:137)
>>>        at org.apache.cxf.tools.wsdlto.WSDLToJavaContainer.execute(WSDLToJavaContainer.java:280)
>>>        ... 4 more
>>> Caused by: javax.wsdl.WSDLException: WSDLException (at
>>> /wsdl:definitions/wsdl:import): faultCode=PARSER_ERROR: Problem
>>> parsing 'http://server:80/app/services/MyService?wsdl=MyServicePortType.wsdl'.:
>>> org.xml.sax.SAXParseException: White spaces are required between
>>> publicId and systemId.
>>>        at com.ibm.wsdl.xml.WSDLReaderImpl.getDocument(Unknown Source)
>>>        at com.ibm.wsdl.xml.WSDLReaderImpl.parseImport(Unknown Source)
>>>        at com.ibm.wsdl.xml.WSDLReaderImpl.parseDefinitions(Unknown Source)
>>>        at com.ibm.wsdl.xml.WSDLReaderImpl.readWSDL(Unknown Source)
>>>        at com.ibm.wsdl.xml.WSDLReaderImpl.readWSDL(Unknown Source)
>>>        at org.apache.cxf.wsdl11.WSDLManagerImpl.loadDefinition(WSDLManagerImpl.java:237)
>>>        at org.apache.cxf.wsdl11.WSDLManagerImpl.getDefinition(WSDLManagerImpl.java:186)
>>>        at org.apache.cxf.wsdl11.WSDLDefinitionBuilder.parseWSDL(WSDLDefinitionBuilder.java:78)
>>>        ... 10 more
>>> Caused by: org.xml.sax.SAXParseExceptionpublicId:
>>> http://server:80/app/services/MyService?wsdl=MyServicePortType.wsdl;
>>> systemId: http://server:80/app/services/MyService?wsdl=MyServicePortType.wsdl;
>>> lineNumber: 1; columnNumber: 50; White spaces are required between
>>> publicId and systemId.
>>>        at com.sun.org.apache.xerces.internal.parsers.DOMParser.parse(Unknown
>>> Source)
>>>        at com.sun.org.apache.xerces.internal.jaxp.DocumentBuilderImpl.parse(Unknown
>>> Source)
>>>        ... 18 more
>>>
>>> 2012/3/7 Aki Yoshida <el...@googlemail.com>
>>>>
>>>> Is there any possibility to define your import location url relative
>>>> to the original location? If that works out, that might probably solve
>>>> the problem.
>>>>
>>>> 2012/3/7 Xavier López <xa...@gmail.com>:
>>>> > Hi. I've deployed a contract-first web service using CXF.
>>>> >
>>>> > The server into which it is deployed performs 302 redirections from http to
>>>> > ssl, so any request to http://server/app/* returns an HTTP 302 error code
>>>> > and redirects to https://server/app/*.
>>>> >
>>>> > In the original WSDL there are references to XSD elements in another
>>>> > namespace, so the generated WSDL (the one
>>>> > http://server/app/services/MyService?wsdl provides) contains a
>>>> > `<wsdl:import>` element.
>>>> >
>>>> > If I try to invoke the WS by manually building a SOAP request in a String
>>>> > and send it over an SSL socket, the WS responds correctly. I've got all
>>>> > necessary certificates in my keystore.
>>>> >
>>>> > However, when I try to build a client using CXF's wsdl2java pointing to `
>>>> > https://server/app/services/MyService?wsdl`, I get the following error:
>>>> >
>>>> >    [Fatal Error] MyService?wsdl=MyServicePortType.wsdl:1:50: White spaces
>>>> > are required between publicId and systemId.
>>>> >
>>>> >    WSDLToJava Error: org.apache.cxf.wsdl11.WSDLRuntimeException:
>>>> >    Fail to create wsdl definition from :
>>>> > https://server/app/services/MyService?wsdl
>>>> >    Caused by : WSDLException (at /wsdl:definitions/wsdl:import):
>>>> >    faultCode=PARSER_ERROR: Problem parsing '
>>>> > http://server:80/app/services/MyService?wsdl=MyServicePortType.wsdl'.:
>>>> >    org.xml.sax.SAXParseException: White spaces are required between
>>>> > publicId and systemId.
>>>> >
>>>> > The trace is referring to the `<wsdl:import>` statement. Its `location`
>>>> > attribute is `
>>>> > http://server:80/app/services/MyService?wsdl=MyServicePortType.wsdl`. My
>>>> > guess is that the error is thrown because of the 302 redirection.
>>>> >
>>>> > The original WSDL is URL-agnostic, and the service's URL is defined
>>>> > relative. It is accessed through the CXF servlet.
>>>> >
>>>> > Should I specify somewhere in the service's autogenerated classes or wsdl
>>>> > that the service is to be deployed on SSL? And how could I do it?

Re: Consuming a webservice with over SSL redirection

Posted by Xavier López <xa...@gmail.com>.
It turns out the service implementation mypackage.MyServiceImpl was
missing the javax.jws.WebService annotation.

Once included with the proper serviceName, portName, targetNamespace,
and endpointInterface attributes, the service deployed without
<wsdl:import>. I suspect this has to do mainly with the
targetNamespace attribute.

However, external XSD's still get referenced with http addresses, like
`. I referenced them relative in the original WSDL. The only solution
to this for me has been inlining all XSD definitions in the original
WSDL. Does anyone know an alternative solution so I can properly have
schemas in an external XSD?

Many thanks,
Xavier

2012/3/7 Aki Yoshida <el...@googlemail.com>:
> Hi Xavier,
> Yes. I meant for the wsdl's imports. But I don't know how your wsdl is
> built or generated. If it is automatically generated, you probably
> can't change that import's location.
>
> Maybe, there might be a property you can configure to follow the
> redirection, but I don't know. Maybe, someone else can help.
>
> regards, aki
>
> 2012/3/7 Xavier López <xa...@gmail.com>:
>> Thanks for your response, Aki. I don't know the way, if there's any.
>> I'd appreciate any tip on this matter.
>>
>> Is this actually a defect in the XML parser, unable to follow the redirect ?
>>
>> I forgot specifying my service's URL is defined relative to the app,
>> in a Spring <jaxws:endpoint>, like this:
>>
>> <import resource="classpath:META-INF/cxf/cxf.xml"/>
>> <import resource="classpath:META-INF/cxf/cxf-extension-soap.xml" />
>> <import resource="classpath:META-INF/cxf/cxf-servlet.xml"/>
>> <bean id="myServiceBean" class="mypackage.MyServiceImpl" />
>> <jaxws:endpoint
>>     id="myServiceEndpoint"
>>     implementor="#myServiceBean"
>>     address="/MyService">
>> </jaxws:endpoint>
>>
>> Maybe I should investigate how is that
>> "http://server:80/app/services/MyService?wsdl=MyServicePortType.wsdl"
>> address made up.
>>
>> I'll also post a complete stack trace, just in case.
>>
>> D:\>wsdl2java -d src -client -impl -verbose -db xmlbeans
>> -autoNameResolution -validate -compile -classdir classes
>> https://server/app/services/MyService?wsdl
>> Loading FrontEnd jaxws ...
>> Loading DataBinding xmlbeans ...
>> wsdl2java -d src -client -impl -verbose -db xmlbeans -autoNameResolution -valida
>> te -compile -classdir classes https://server/app/services/MyService?wsdl
>> wsdl2java - Apache CXF 2.3.2
>>
>> [Fatal Error] MyService?wsdl=MyServicePortType.wsdl:1:50: White spaces
>> are required between publicId and systemId.
>>
>> WSDLToJava Error: org.apache.cxf.wsdl11.WSDLRuntimeException: Fail to
>> create wsdl definition from :
>> https://server/app/services/MyService?wsdl
>> Caused by : WSDLException (at /wsdl:definitions/wsdl:import):
>> faultCode=PARSER_ERROR: Problem parsing
>> 'http://server:80/app/services/MyService?wsdl=MyServicePortType.wsdl'.:
>> org.xml.sax.SAXParseException: White spaces are required between
>> publicId and systemId.
>>
>> org.apache.cxf.tools.common.ToolException:
>> org.apache.cxf.wsdl11.WSDLRuntimeException: Fail to create wsdl
>> definition from : https://server/app/services/MyService?wsdl
>> Caused by : WSDLException (at /wsdl:definitions/wsdl:import):
>> faultCode=PARSER_ERROR: Problem parsing
>> 'http://server:80/app/services/MyService?wsdl=MyServicePortType.wsdl'.:
>> org.xml.sax.SAXParseException: White spaces are required between
>> publicId and systemId.
>>        at org.apache.cxf.tools.wsdlto.WSDLToJavaContainer.execute(WSDLToJavaContainer.java:288)
>>        at org.apache.cxf.tools.common.toolspec.ToolRunner.runTool(ToolRunner.java:103)
>>        at org.apache.cxf.tools.wsdlto.WSDLToJava.run(WSDLToJava.java:113)
>>        at org.apache.cxf.tools.wsdlto.WSDLToJava.run(WSDLToJava.java:86)
>>        at org.apache.cxf.tools.wsdlto.WSDLToJava.main(WSDLToJava.java:184)
>> Caused by: org.apache.cxf.wsdl11.WSDLRuntimeException: Fail to create
>> wsdl definition from : https://server/app/services/MyService?wsdl
>> Caused by : WSDLException (at /wsdl:definitions/wsdl:import):
>> faultCode=PARSER_ERROR: Problem parsing
>> 'http://server:80/app/services/MyService?wsdl=MyServicePortType.wsdl'.:
>> org.xml.sax.SAXParseException: White spaces are required between
>> publicId and systemId.
>>        at org.apache.cxf.wsdl11.WSDLDefinitionBuilder.parseWSDL(WSDLDefinitionBuilder.java:97)
>>        at org.apache.cxf.wsdl11.WSDLDefinitionBuilder.build(WSDLDefinitionBuilder.java:69)
>>        at org.apache.cxf.tools.wsdlto.frontend.jaxws.wsdl11.JAXWSDefinitionBuilder.build(JAXWSDefinitionBuilder.java:84)
>>        at org.apache.cxf.tools.wsdlto.frontend.jaxws.wsdl11.JAXWSDefinitionBuilder.build(JAXWSDefinitionBuilder.java:61)
>>        at org.apache.cxf.tools.wsdlto.WSDLToJavaContainer.processWsdl(WSDLToJavaContainer.java:170)
>>        at org.apache.cxf.tools.wsdlto.WSDLToJavaContainer.execute(WSDLToJavaContainer.java:137)
>>        at org.apache.cxf.tools.wsdlto.WSDLToJavaContainer.execute(WSDLToJavaContainer.java:280)
>>        ... 4 more
>> Caused by: javax.wsdl.WSDLException: WSDLException (at
>> /wsdl:definitions/wsdl:import): faultCode=PARSER_ERROR: Problem
>> parsing 'http://server:80/app/services/MyService?wsdl=MyServicePortType.wsdl'.:
>> org.xml.sax.SAXParseException: White spaces are required between
>> publicId and systemId.
>>        at com.ibm.wsdl.xml.WSDLReaderImpl.getDocument(Unknown Source)
>>        at com.ibm.wsdl.xml.WSDLReaderImpl.parseImport(Unknown Source)
>>        at com.ibm.wsdl.xml.WSDLReaderImpl.parseDefinitions(Unknown Source)
>>        at com.ibm.wsdl.xml.WSDLReaderImpl.readWSDL(Unknown Source)
>>        at com.ibm.wsdl.xml.WSDLReaderImpl.readWSDL(Unknown Source)
>>        at org.apache.cxf.wsdl11.WSDLManagerImpl.loadDefinition(WSDLManagerImpl.java:237)
>>        at org.apache.cxf.wsdl11.WSDLManagerImpl.getDefinition(WSDLManagerImpl.java:186)
>>        at org.apache.cxf.wsdl11.WSDLDefinitionBuilder.parseWSDL(WSDLDefinitionBuilder.java:78)
>>        ... 10 more
>> Caused by: org.xml.sax.SAXParseExceptionpublicId:
>> http://server:80/app/services/MyService?wsdl=MyServicePortType.wsdl;
>> systemId: http://server:80/app/services/MyService?wsdl=MyServicePortType.wsdl;
>> lineNumber: 1; columnNumber: 50; White spaces are required between
>> publicId and systemId.
>>        at com.sun.org.apache.xerces.internal.parsers.DOMParser.parse(Unknown
>> Source)
>>        at com.sun.org.apache.xerces.internal.jaxp.DocumentBuilderImpl.parse(Unknown
>> Source)
>>        ... 18 more
>>
>> 2012/3/7 Aki Yoshida <el...@googlemail.com>
>>>
>>> Is there any possibility to define your import location url relative
>>> to the original location? If that works out, that might probably solve
>>> the problem.
>>>
>>> 2012/3/7 Xavier López <xa...@gmail.com>:
>>> > Hi. I've deployed a contract-first web service using CXF.
>>> >
>>> > The server into which it is deployed performs 302 redirections from http to
>>> > ssl, so any request to http://server/app/* returns an HTTP 302 error code
>>> > and redirects to https://server/app/*.
>>> >
>>> > In the original WSDL there are references to XSD elements in another
>>> > namespace, so the generated WSDL (the one
>>> > http://server/app/services/MyService?wsdl provides) contains a
>>> > `<wsdl:import>` element.
>>> >
>>> > If I try to invoke the WS by manually building a SOAP request in a String
>>> > and send it over an SSL socket, the WS responds correctly. I've got all
>>> > necessary certificates in my keystore.
>>> >
>>> > However, when I try to build a client using CXF's wsdl2java pointing to `
>>> > https://server/app/services/MyService?wsdl`, I get the following error:
>>> >
>>> >    [Fatal Error] MyService?wsdl=MyServicePortType.wsdl:1:50: White spaces
>>> > are required between publicId and systemId.
>>> >
>>> >    WSDLToJava Error: org.apache.cxf.wsdl11.WSDLRuntimeException:
>>> >    Fail to create wsdl definition from :
>>> > https://server/app/services/MyService?wsdl
>>> >    Caused by : WSDLException (at /wsdl:definitions/wsdl:import):
>>> >    faultCode=PARSER_ERROR: Problem parsing '
>>> > http://server:80/app/services/MyService?wsdl=MyServicePortType.wsdl'.:
>>> >    org.xml.sax.SAXParseException: White spaces are required between
>>> > publicId and systemId.
>>> >
>>> > The trace is referring to the `<wsdl:import>` statement. Its `location`
>>> > attribute is `
>>> > http://server:80/app/services/MyService?wsdl=MyServicePortType.wsdl`. My
>>> > guess is that the error is thrown because of the 302 redirection.
>>> >
>>> > The original WSDL is URL-agnostic, and the service's URL is defined
>>> > relative. It is accessed through the CXF servlet.
>>> >
>>> > Should I specify somewhere in the service's autogenerated classes or wsdl
>>> > that the service is to be deployed on SSL? And how could I do it?

Re: Consuming a webservice with over SSL redirection

Posted by Aki Yoshida <el...@googlemail.com>.
Hi Xavier,
Yes. I meant for the wsdl's imports. But I don't know how your wsdl is
built or generated. If it is automatically generated, you probably
can't change that import's location.

Maybe, there might be a property you can configure to follow the
redirection, but I don't know. Maybe, someone else can help.

regards, aki

2012/3/7 Xavier López <xa...@gmail.com>:
> Thanks for your response, Aki. I don't know the way, if there's any.
> I'd appreciate any tip on this matter.
>
> Is this actually a defect in the XML parser, unable to follow the redirect ?
>
> I forgot specifying my service's URL is defined relative to the app,
> in a Spring <jaxws:endpoint>, like this:
>
> <import resource="classpath:META-INF/cxf/cxf.xml"/>
> <import resource="classpath:META-INF/cxf/cxf-extension-soap.xml" />
> <import resource="classpath:META-INF/cxf/cxf-servlet.xml"/>
> <bean id="myServiceBean" class="mypackage.MyServiceImpl" />
> <jaxws:endpoint
>     id="myServiceEndpoint"
>     implementor="#myServiceBean"
>     address="/MyService">
> </jaxws:endpoint>
>
> Maybe I should investigate how is that
> "http://server:80/app/services/MyService?wsdl=MyServicePortType.wsdl"
> address made up.
>
> I'll also post a complete stack trace, just in case.
>
> D:\>wsdl2java -d src -client -impl -verbose -db xmlbeans
> -autoNameResolution -validate -compile -classdir classes
> https://server/app/services/MyService?wsdl
> Loading FrontEnd jaxws ...
> Loading DataBinding xmlbeans ...
> wsdl2java -d src -client -impl -verbose -db xmlbeans -autoNameResolution -valida
> te -compile -classdir classes https://server/app/services/MyService?wsdl
> wsdl2java - Apache CXF 2.3.2
>
> [Fatal Error] MyService?wsdl=MyServicePortType.wsdl:1:50: White spaces
> are required between publicId and systemId.
>
> WSDLToJava Error: org.apache.cxf.wsdl11.WSDLRuntimeException: Fail to
> create wsdl definition from :
> https://server/app/services/MyService?wsdl
> Caused by : WSDLException (at /wsdl:definitions/wsdl:import):
> faultCode=PARSER_ERROR: Problem parsing
> 'http://server:80/app/services/MyService?wsdl=MyServicePortType.wsdl'.:
> org.xml.sax.SAXParseException: White spaces are required between
> publicId and systemId.
>
> org.apache.cxf.tools.common.ToolException:
> org.apache.cxf.wsdl11.WSDLRuntimeException: Fail to create wsdl
> definition from : https://server/app/services/MyService?wsdl
> Caused by : WSDLException (at /wsdl:definitions/wsdl:import):
> faultCode=PARSER_ERROR: Problem parsing
> 'http://server:80/app/services/MyService?wsdl=MyServicePortType.wsdl'.:
> org.xml.sax.SAXParseException: White spaces are required between
> publicId and systemId.
>        at org.apache.cxf.tools.wsdlto.WSDLToJavaContainer.execute(WSDLToJavaContainer.java:288)
>        at org.apache.cxf.tools.common.toolspec.ToolRunner.runTool(ToolRunner.java:103)
>        at org.apache.cxf.tools.wsdlto.WSDLToJava.run(WSDLToJava.java:113)
>        at org.apache.cxf.tools.wsdlto.WSDLToJava.run(WSDLToJava.java:86)
>        at org.apache.cxf.tools.wsdlto.WSDLToJava.main(WSDLToJava.java:184)
> Caused by: org.apache.cxf.wsdl11.WSDLRuntimeException: Fail to create
> wsdl definition from : https://server/app/services/MyService?wsdl
> Caused by : WSDLException (at /wsdl:definitions/wsdl:import):
> faultCode=PARSER_ERROR: Problem parsing
> 'http://server:80/app/services/MyService?wsdl=MyServicePortType.wsdl'.:
> org.xml.sax.SAXParseException: White spaces are required between
> publicId and systemId.
>        at org.apache.cxf.wsdl11.WSDLDefinitionBuilder.parseWSDL(WSDLDefinitionBuilder.java:97)
>        at org.apache.cxf.wsdl11.WSDLDefinitionBuilder.build(WSDLDefinitionBuilder.java:69)
>        at org.apache.cxf.tools.wsdlto.frontend.jaxws.wsdl11.JAXWSDefinitionBuilder.build(JAXWSDefinitionBuilder.java:84)
>        at org.apache.cxf.tools.wsdlto.frontend.jaxws.wsdl11.JAXWSDefinitionBuilder.build(JAXWSDefinitionBuilder.java:61)
>        at org.apache.cxf.tools.wsdlto.WSDLToJavaContainer.processWsdl(WSDLToJavaContainer.java:170)
>        at org.apache.cxf.tools.wsdlto.WSDLToJavaContainer.execute(WSDLToJavaContainer.java:137)
>        at org.apache.cxf.tools.wsdlto.WSDLToJavaContainer.execute(WSDLToJavaContainer.java:280)
>        ... 4 more
> Caused by: javax.wsdl.WSDLException: WSDLException (at
> /wsdl:definitions/wsdl:import): faultCode=PARSER_ERROR: Problem
> parsing 'http://server:80/app/services/MyService?wsdl=MyServicePortType.wsdl'.:
> org.xml.sax.SAXParseException: White spaces are required between
> publicId and systemId.
>        at com.ibm.wsdl.xml.WSDLReaderImpl.getDocument(Unknown Source)
>        at com.ibm.wsdl.xml.WSDLReaderImpl.parseImport(Unknown Source)
>        at com.ibm.wsdl.xml.WSDLReaderImpl.parseDefinitions(Unknown Source)
>        at com.ibm.wsdl.xml.WSDLReaderImpl.readWSDL(Unknown Source)
>        at com.ibm.wsdl.xml.WSDLReaderImpl.readWSDL(Unknown Source)
>        at org.apache.cxf.wsdl11.WSDLManagerImpl.loadDefinition(WSDLManagerImpl.java:237)
>        at org.apache.cxf.wsdl11.WSDLManagerImpl.getDefinition(WSDLManagerImpl.java:186)
>        at org.apache.cxf.wsdl11.WSDLDefinitionBuilder.parseWSDL(WSDLDefinitionBuilder.java:78)
>        ... 10 more
> Caused by: org.xml.sax.SAXParseExceptionpublicId:
> http://server:80/app/services/MyService?wsdl=MyServicePortType.wsdl;
> systemId: http://server:80/app/services/MyService?wsdl=MyServicePortType.wsdl;
> lineNumber: 1; columnNumber: 50; White spaces are required between
> publicId and systemId.
>        at com.sun.org.apache.xerces.internal.parsers.DOMParser.parse(Unknown
> Source)
>        at com.sun.org.apache.xerces.internal.jaxp.DocumentBuilderImpl.parse(Unknown
> Source)
>        ... 18 more
>
> 2012/3/7 Aki Yoshida <el...@googlemail.com>
>>
>> Is there any possibility to define your import location url relative
>> to the original location? If that works out, that might probably solve
>> the problem.
>>
>> 2012/3/7 Xavier López <xa...@gmail.com>:
>> > Hi. I've deployed a contract-first web service using CXF.
>> >
>> > The server into which it is deployed performs 302 redirections from http to
>> > ssl, so any request to http://server/app/* returns an HTTP 302 error code
>> > and redirects to https://server/app/*.
>> >
>> > In the original WSDL there are references to XSD elements in another
>> > namespace, so the generated WSDL (the one
>> > http://server/app/services/MyService?wsdl provides) contains a
>> > `<wsdl:import>` element.
>> >
>> > If I try to invoke the WS by manually building a SOAP request in a String
>> > and send it over an SSL socket, the WS responds correctly. I've got all
>> > necessary certificates in my keystore.
>> >
>> > However, when I try to build a client using CXF's wsdl2java pointing to `
>> > https://server/app/services/MyService?wsdl`, I get the following error:
>> >
>> >    [Fatal Error] MyService?wsdl=MyServicePortType.wsdl:1:50: White spaces
>> > are required between publicId and systemId.
>> >
>> >    WSDLToJava Error: org.apache.cxf.wsdl11.WSDLRuntimeException:
>> >    Fail to create wsdl definition from :
>> > https://server/app/services/MyService?wsdl
>> >    Caused by : WSDLException (at /wsdl:definitions/wsdl:import):
>> >    faultCode=PARSER_ERROR: Problem parsing '
>> > http://server:80/app/services/MyService?wsdl=MyServicePortType.wsdl'.:
>> >    org.xml.sax.SAXParseException: White spaces are required between
>> > publicId and systemId.
>> >
>> > The trace is referring to the `<wsdl:import>` statement. Its `location`
>> > attribute is `
>> > http://server:80/app/services/MyService?wsdl=MyServicePortType.wsdl`. My
>> > guess is that the error is thrown because of the 302 redirection.
>> >
>> > The original WSDL is URL-agnostic, and the service's URL is defined
>> > relative. It is accessed through the CXF servlet.
>> >
>> > Should I specify somewhere in the service's autogenerated classes or wsdl
>> > that the service is to be deployed on SSL? And how could I do it?

Re: Consuming a webservice with over SSL redirection

Posted by Xavier López <xa...@gmail.com>.
Thanks for your response, Aki. I don't know the way, if there's any.
I'd appreciate any tip on this matter.

Is this actually a defect in the XML parser, unable to follow the redirect ?

I forgot specifying my service's URL is defined relative to the app,
in a Spring <jaxws:endpoint>, like this:

<import resource="classpath:META-INF/cxf/cxf.xml"/>
<import resource="classpath:META-INF/cxf/cxf-extension-soap.xml" />
<import resource="classpath:META-INF/cxf/cxf-servlet.xml"/>
<bean id="myServiceBean" class="mypackage.MyServiceImpl" />
<jaxws:endpoint
    id="myServiceEndpoint"
    implementor="#myServiceBean"
    address="/MyService">
</jaxws:endpoint>

Maybe I should investigate how is that
"http://server:80/app/services/MyService?wsdl=MyServicePortType.wsdl"
address made up.

I'll also post a complete stack trace, just in case.

D:\>wsdl2java -d src -client -impl -verbose -db xmlbeans
-autoNameResolution -validate -compile -classdir classes
https://server/app/services/MyService?wsdl
Loading FrontEnd jaxws ...
Loading DataBinding xmlbeans ...
wsdl2java -d src -client -impl -verbose -db xmlbeans -autoNameResolution -valida
te -compile -classdir classes https://server/app/services/MyService?wsdl
wsdl2java - Apache CXF 2.3.2

[Fatal Error] MyService?wsdl=MyServicePortType.wsdl:1:50: White spaces
are required between publicId and systemId.

WSDLToJava Error: org.apache.cxf.wsdl11.WSDLRuntimeException: Fail to
create wsdl definition from :
https://server/app/services/MyService?wsdl
Caused by : WSDLException (at /wsdl:definitions/wsdl:import):
faultCode=PARSER_ERROR: Problem parsing
'http://server:80/app/services/MyService?wsdl=MyServicePortType.wsdl'.:
org.xml.sax.SAXParseException: White spaces are required between
publicId and systemId.

org.apache.cxf.tools.common.ToolException:
org.apache.cxf.wsdl11.WSDLRuntimeException: Fail to create wsdl
definition from : https://server/app/services/MyService?wsdl
Caused by : WSDLException (at /wsdl:definitions/wsdl:import):
faultCode=PARSER_ERROR: Problem parsing
'http://server:80/app/services/MyService?wsdl=MyServicePortType.wsdl'.:
org.xml.sax.SAXParseException: White spaces are required between
publicId and systemId.
        at org.apache.cxf.tools.wsdlto.WSDLToJavaContainer.execute(WSDLToJavaContainer.java:288)
        at org.apache.cxf.tools.common.toolspec.ToolRunner.runTool(ToolRunner.java:103)
        at org.apache.cxf.tools.wsdlto.WSDLToJava.run(WSDLToJava.java:113)
        at org.apache.cxf.tools.wsdlto.WSDLToJava.run(WSDLToJava.java:86)
        at org.apache.cxf.tools.wsdlto.WSDLToJava.main(WSDLToJava.java:184)
Caused by: org.apache.cxf.wsdl11.WSDLRuntimeException: Fail to create
wsdl definition from : https://server/app/services/MyService?wsdl
Caused by : WSDLException (at /wsdl:definitions/wsdl:import):
faultCode=PARSER_ERROR: Problem parsing
'http://server:80/app/services/MyService?wsdl=MyServicePortType.wsdl'.:
org.xml.sax.SAXParseException: White spaces are required between
publicId and systemId.
        at org.apache.cxf.wsdl11.WSDLDefinitionBuilder.parseWSDL(WSDLDefinitionBuilder.java:97)
        at org.apache.cxf.wsdl11.WSDLDefinitionBuilder.build(WSDLDefinitionBuilder.java:69)
        at org.apache.cxf.tools.wsdlto.frontend.jaxws.wsdl11.JAXWSDefinitionBuilder.build(JAXWSDefinitionBuilder.java:84)
        at org.apache.cxf.tools.wsdlto.frontend.jaxws.wsdl11.JAXWSDefinitionBuilder.build(JAXWSDefinitionBuilder.java:61)
        at org.apache.cxf.tools.wsdlto.WSDLToJavaContainer.processWsdl(WSDLToJavaContainer.java:170)
        at org.apache.cxf.tools.wsdlto.WSDLToJavaContainer.execute(WSDLToJavaContainer.java:137)
        at org.apache.cxf.tools.wsdlto.WSDLToJavaContainer.execute(WSDLToJavaContainer.java:280)
        ... 4 more
Caused by: javax.wsdl.WSDLException: WSDLException (at
/wsdl:definitions/wsdl:import): faultCode=PARSER_ERROR: Problem
parsing 'http://server:80/app/services/MyService?wsdl=MyServicePortType.wsdl'.:
org.xml.sax.SAXParseException: White spaces are required between
publicId and systemId.
        at com.ibm.wsdl.xml.WSDLReaderImpl.getDocument(Unknown Source)
        at com.ibm.wsdl.xml.WSDLReaderImpl.parseImport(Unknown Source)
        at com.ibm.wsdl.xml.WSDLReaderImpl.parseDefinitions(Unknown Source)
        at com.ibm.wsdl.xml.WSDLReaderImpl.readWSDL(Unknown Source)
        at com.ibm.wsdl.xml.WSDLReaderImpl.readWSDL(Unknown Source)
        at org.apache.cxf.wsdl11.WSDLManagerImpl.loadDefinition(WSDLManagerImpl.java:237)
        at org.apache.cxf.wsdl11.WSDLManagerImpl.getDefinition(WSDLManagerImpl.java:186)
        at org.apache.cxf.wsdl11.WSDLDefinitionBuilder.parseWSDL(WSDLDefinitionBuilder.java:78)
        ... 10 more
Caused by: org.xml.sax.SAXParseExceptionpublicId:
http://server:80/app/services/MyService?wsdl=MyServicePortType.wsdl;
systemId: http://server:80/app/services/MyService?wsdl=MyServicePortType.wsdl;
lineNumber: 1; columnNumber: 50; White spaces are required between
publicId and systemId.
        at com.sun.org.apache.xerces.internal.parsers.DOMParser.parse(Unknown
Source)
        at com.sun.org.apache.xerces.internal.jaxp.DocumentBuilderImpl.parse(Unknown
Source)
        ... 18 more

2012/3/7 Aki Yoshida <el...@googlemail.com>
>
> Is there any possibility to define your import location url relative
> to the original location? If that works out, that might probably solve
> the problem.
>
> 2012/3/7 Xavier López <xa...@gmail.com>:
> > Hi. I've deployed a contract-first web service using CXF.
> >
> > The server into which it is deployed performs 302 redirections from http to
> > ssl, so any request to http://server/app/* returns an HTTP 302 error code
> > and redirects to https://server/app/*.
> >
> > In the original WSDL there are references to XSD elements in another
> > namespace, so the generated WSDL (the one
> > http://server/app/services/MyService?wsdl provides) contains a
> > `<wsdl:import>` element.
> >
> > If I try to invoke the WS by manually building a SOAP request in a String
> > and send it over an SSL socket, the WS responds correctly. I've got all
> > necessary certificates in my keystore.
> >
> > However, when I try to build a client using CXF's wsdl2java pointing to `
> > https://server/app/services/MyService?wsdl`, I get the following error:
> >
> >    [Fatal Error] MyService?wsdl=MyServicePortType.wsdl:1:50: White spaces
> > are required between publicId and systemId.
> >
> >    WSDLToJava Error: org.apache.cxf.wsdl11.WSDLRuntimeException:
> >    Fail to create wsdl definition from :
> > https://server/app/services/MyService?wsdl
> >    Caused by : WSDLException (at /wsdl:definitions/wsdl:import):
> >    faultCode=PARSER_ERROR: Problem parsing '
> > http://server:80/app/services/MyService?wsdl=MyServicePortType.wsdl'.:
> >    org.xml.sax.SAXParseException: White spaces are required between
> > publicId and systemId.
> >
> > The trace is referring to the `<wsdl:import>` statement. Its `location`
> > attribute is `
> > http://server:80/app/services/MyService?wsdl=MyServicePortType.wsdl`. My
> > guess is that the error is thrown because of the 302 redirection.
> >
> > The original WSDL is URL-agnostic, and the service's URL is defined
> > relative. It is accessed through the CXF servlet.
> >
> > Should I specify somewhere in the service's autogenerated classes or wsdl
> > that the service is to be deployed on SSL? And how could I do it?

Re: Consuming a webservice with over SSL redirection

Posted by Aki Yoshida <el...@googlemail.com>.
Is there any possibility to define your import location url relative
to the original location? If that works out, that might probably solve
the problem.

2012/3/7 Xavier López <xa...@gmail.com>:
> Hi. I've deployed a contract-first web service using CXF.
>
> The server into which it is deployed performs 302 redirections from http to
> ssl, so any request to http://server/app/* returns an HTTP 302 error code
> and redirects to https://server/app/*.
>
> In the original WSDL there are references to XSD elements in another
> namespace, so the generated WSDL (the one
> http://server/app/services/MyService?wsdl provides) contains a
> `<wsdl:import>` element.
>
> If I try to invoke the WS by manually building a SOAP request in a String
> and send it over an SSL socket, the WS responds correctly. I've got all
> necessary certificates in my keystore.
>
> However, when I try to build a client using CXF's wsdl2java pointing to `
> https://server/app/services/MyService?wsdl`, I get the following error:
>
>    [Fatal Error] MyService?wsdl=MyServicePortType.wsdl:1:50: White spaces
> are required between publicId and systemId.
>
>    WSDLToJava Error: org.apache.cxf.wsdl11.WSDLRuntimeException:
>    Fail to create wsdl definition from :
> https://server/app/services/MyService?wsdl
>    Caused by : WSDLException (at /wsdl:definitions/wsdl:import):
>    faultCode=PARSER_ERROR: Problem parsing '
> http://server:80/app/services/MyService?wsdl=MyServicePortType.wsdl'.:
>    org.xml.sax.SAXParseException: White spaces are required between
> publicId and systemId.
>
> The trace is referring to the `<wsdl:import>` statement. Its `location`
> attribute is `
> http://server:80/app/services/MyService?wsdl=MyServicePortType.wsdl`. My
> guess is that the error is thrown because of the 302 redirection.
>
> The original WSDL is URL-agnostic, and the service's URL is defined
> relative. It is accessed through the CXF servlet.
>
> Should I specify somewhere in the service's autogenerated classes or wsdl
> that the service is to be deployed on SSL? And how could I do it?