SOAP xml response received but not populating response object

后端 未结 2 1869
余生分开走
余生分开走 2021-01-17 20:12

I added a "Service Reference" to a vendor\'s Java based web service which i have no control over.

I have this simple client code:

   Client m         


        
相关标签:
2条回答
  • 2021-01-17 21:00

    I was able to figure out my problem: There was a namespace mismatch.

    The body of my request soap envelope contained:

    <csw:GetCapabilities 
    xmlns:csw="http://www.opengis.net/cat/csw/2.0.2" 
    xmlns:dc="http://purl.org/dc/elements/1.1/" 
    xmlns:dct="http://purl.org/dc/terms/" 
    xmlns:sch="http://www.ascc.net/xml/schematron" 
    xmlns:gml="http://www.opengis.net/gml" 
    xmlns:ogc="http://www.opengis.net/ogc" 
    xmlns:ows="http://www.opengis.net/ows" 
    xmlns:xlink="http://www.w3.org/1999/xlink" />
    

    In the response i was getting (top relevant characters only):

    <wrs:Capabilities xmlns:wrs="http://www.opengis.net/cat/wrs/1.0" xmlns:csw="http://www.opengis.net/cat/csw" xmlns:ogc="http://www.opengis.net/ogc" xmlns:ows="http://www.opengeospatial.net/ows" xmlns:xlink="http://www.w3.org/1999/xlink" version="1.0.0">
    

    Notice how the OWS schema namespace in the REQUEST is pointing to http://www.opengis.net/ows

    While the response is pointing to http://www.opengeospatial.net/ows

    Both namespaces have to be the same for .NET to deserialize the data. So you could just have the response respond the correct namespace. In my case, since i had no control over the Java Web Service, i had to modify the auto-generated proxy class and replace all instances of “xmlns:ows=http://www.opengis.net/ows” for “xmlns:ows=http://www.opengeospatial.net/ows”

    0 讨论(0)
  • 2021-01-17 21:08

    Maybe you might try to generate a client proxy using SvcUtil instead of using a service reference. I am unaware as to whether they would generate the same client code, but you might as well try it anyway.

    svcutil /target:code http://www.xyz.com/webService.wsdl /out:XYZWebServzice.cs
    
    0 讨论(0)
提交回复
热议问题