Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Service reference not loading: Schema with target namespace could not be found

I'm trying to add a Service Reference to my project and I'm getting constantly the same error.

I've created a mock service with SOAP UI that seems fine, then I try to add a service reference to this mock service and the error appears:

Warning 14  Custom tool warning: Cannot import wsdl:portType
Detail: An exception was thrown while running a WSDL import extension:     System.ServiceModel.Description.DataContractSerializerMessageContractImporter
Error: Schema with target namespace 'urn:oasis:names:tc:dss:1.0:core:schema' could not be found.
XPath to Error Source: //wsdl:definitions[@targetNamespace='http://tempuri.org/esign']/wsdl:portType[@name='EsignServiceSoap11PortType']    

The import on the wsdl where schema with namespace urn:oasis:names:tc:dss:1.0:core:schema is being loaded is:

<wsdl:types>

      <schema xmlns="urn:oasis:names:tc:dss:1.0:core:schema">

           <import namespace="urn:oasis:names:tc:dss:1.0:core:schema" schemaLocation="oasis-dss-core-schema-v1.0-os.xsd"/>

      </schema>

    .....
</wsdl:types>

I've already tried to link the schemaLocation directly to the file in the same folder than the wsdl, to a url where it's published in a private server and to a public uri where it's also published.

I get always the same error and I'm starting to feel that maybe I'm mistaken with the source of the problem.

Any insight will be much appreciated.

UPDATE: I've injected urn:oasis:names:tc:dss:1.0:core:schema complete definition inside my wsdl file, instead of trying to import it. When I do so, SOAP UI still creates correctly the mocking service, however, when I try to add a Service Reference, this error is thrown during service discovery:

The document was understood, but it could not be processed.
  - The WSDL document contains links that could not be resolved.
  - DTD is prohibited in this XML document.
Metadata contains a reference that cannot be resolved:    'http://elite8100-3:8088/mockEsignServiceSoap11Binding?WSDL'.
The content type text/html; charset=iso-8859-1 of the response message does not match the content type of the binding (application/soap+xml; charset=utf-8). If using a custom encoder, be sure that the IsContentTypeSupported method is implemented properly. The first 455 bytes of the response were: '<soap:Envelope xmlns:soap="http://www.w3.org/2003/05/soap-envelope">
  <soap:Body>
    <soap:Fault>
      <soap:Code>
    <soap:Value>Server</soap:Value>
  </soap:Code>
  <soap:Reason>
    <!--1 or more repetitions:-->
    <soap:Text xml:lang="en">Missing operation for soapAction [null] and body element [null] with SOAP Version [SOAP 1.2]</soap:Text>
  </soap:Reason>
</soap:Fault>
  </soap:Body>
</soap:Envelope>'.
The remote server returned an error: (500) Internal Server Error.
If the service is defined in the current solution, try building the solution and adding the service reference again.

EDIT2: I've used Fiddler to check http traffic when trying to create the proxy, as suggested in the answer. During the creation, a 500 internal server error appears on Fiddler when trying to reach the mockService url, the response from the server was "Missing operation for soapAction [null] and body element [null] with SOAP version [SOAP 1.2]".

This is, currently, the WSDL I'm using to create the mockService.

 <wsdl:types>

      <schema xmlns="http://www.w3.org/2001/XMLSchema">

           <import namespace="http://www.w3.org/2001/XMLSchema" schemaLocation="http://aplicaciones.serpasa.es/CONTROLAMBIENTAL/oasis-dss-core-schema-v1.0-os.xsd"/>

      </schema>

      <schema xmlns="http://princast.es/esign/2.0/esign.xsd">

           <import namespace="http://princast.es/esign/2.0/esign.xsd" schemaLocation="http://aplicaciones.serpasa.es/CONTROLAMBIENTAL/esign.xsd"/>

      </schema>

 </wsdl:types>


 <wsdl:message name="SignRequestMessage">

      <wsdl:part element="dss:SignRequest" name="payload"/>

 </wsdl:message>

 <wsdl:message name="SignResponseMessage">

      <wsdl:part element="dss:SignResponse" name="payload"/>

 </wsdl:message>


 <wsdl:message name="VerifyRequestMessage">

      <wsdl:part element="dss:VerifyRequest" name="payload"/>

 </wsdl:message>

 <wsdl:message name="VerifyResponseMessage">

      <wsdl:part element="dss:VerifyResponse" name="payload"/>

 </wsdl:message>


 <wsdl:message name="GetSignInfoFromDocumentRequestMessage">

      <wsdl:part element="esign:SignInfoRequest" name="payload"/>

 </wsdl:message>

 <wsdl:message name="GetSignInfoFromDocumentResponseMessage">

      <wsdl:part element="esign:SignInfo" name="payload"/>

 </wsdl:message>


 <wsdl:message name="GetSignConfigurationRequestMessage">

      <wsdl:part element="esign:SignConfigurationRequest" name="payload"/>

 </wsdl:message>

 <wsdl:message name="GetSignConfigurationResponseMessage">

      <wsdl:part element="esign:SupportedSignConfiguration" name="payload"/>

 </wsdl:message>


<!-- Port -->


 <wsdl:portType name="EsignServiceSoap11PortType">


      <wsdl:operation name="sign">

           <wsdl:input message="impl:SignRequestMessage" name="signRequest"/>

           <wsdl:output message="impl:SignResponseMessage" name="signResponse"/>

      </wsdl:operation>


      <wsdl:operation name="verify">

           <wsdl:input message="impl:VerifyRequestMessage" name="verifyRequest"/>

           <wsdl:output message="impl:VerifyResponseMessage" name="verifyResponse"/>

      </wsdl:operation>


      <wsdl:operation name="getSignConfiguration">

           <wsdl:input message="impl:GetSignConfigurationRequestMessage" name="getSignConfigurationRequest"/>

           <wsdl:output message="impl:GetSignConfigurationResponseMessage" name="getSignConfigurationResponse"/>

      </wsdl:operation>


      <wsdl:operation name="getSignInfoFromDocument">

           <wsdl:input message="impl:GetSignInfoFromDocumentRequestMessage" name="getSignInfoFromDocumentRequest"/>

           <wsdl:output message="impl:GetSignInfoFromDocumentResponseMessage" name="getSignInfoFromDocumentResponse"/>

      </wsdl:operation>


 </wsdl:portType>


<!-- Binding -->

 <wsdl:binding name="EsignServiceSoap11Binding" type="impl:EsignServiceSoap11PortType">


      <wsdlsoap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"/>


      <wsdl:operation name="sign">

           <wsdl:documentation>

            Realiza una firma digital delegada sobre un
            documento segun el estandard OASIS Digital Signature Service (DSS)
           </wsdl:documentation>


           <wsdlsoap:operation soapAction="urn:sign"/>

           <wsdl:input name="signRequest">

                <wsdlsoap:body use="literal"/>

           </wsdl:input>

           <wsdl:output name="signResponse">

                <wsdlsoap:body use="literal"/>

           </wsdl:output>

      </wsdl:operation>


      <wsdl:operation name="verify">

           <wsdl:documentation>

            Verifica una firma digital OASIS Digital
            Signature Service (DSS)
           </wsdl:documentation>


           <wsdlsoap:operation soapAction="urn:verify"/>

           <wsdl:input name="verifyRequest">

                <wsdlsoap:body use="literal"/>

           </wsdl:input>

           <wsdl:output name="verifyResponse">

                <wsdlsoap:body use="literal"/>

           </wsdl:output>

      </wsdl:operation>


      <wsdl:operation name="getSignConfiguration">

           <wsdl:documentation>

            Obtiene los certificados con los que una
            aplicacion en el MC de Firma Digital puede realizar
            una firma
           </wsdl:documentation>


           <wsdlsoap:operation soapAction="urn:getSignConfiguration"/>

           <wsdl:input name="getSignConfigurationRequest">

                <wsdlsoap:body use="literal"/>

           </wsdl:input>

           <wsdl:output name="getSignConfigurationResponse">

                <wsdlsoap:body use="literal"/>

           </wsdl:output>

      </wsdl:operation>


      <wsdl:operation name="getSignInfoFromDocument">

           <wsdl:documentation>

            Obtiene informacion de un fichero de firma
           </wsdl:documentation>


           <wsdlsoap:operation soapAction="urn:getSignInfoFromDocument"/>

           <wsdl:input name="getSignInfoFromDocumentRequest">

                <wsdlsoap:body use="literal"/>

           </wsdl:input>

           <wsdl:output name="getSignInfoFromDocumentResponse">

                <wsdlsoap:body use="literal"/>

           </wsdl:output>

      </wsdl:operation>


 </wsdl:binding>


 <wsdl:service name="EsignService">


      <wsdl:documentation>

        Servicio web de firma digital 
      </wsdl:documentation>


      <wsdl:port binding="impl:EsignServiceSoap11Binding" name="EsignServiceSoap11Port">


           <wsdlsoap:address location="http://someexternalsite.com"/>


      </wsdl:port>


 </wsdl:service>

I've downloaded every single .xsd associated and published them on a public server, also I've changed schemaLocations so they point to addresses on this public server, however, the problem seems to be related to WSDL structure.

like image 841
Bardo Avatar asked Mar 17 '16 13:03

Bardo


1 Answers

The main issue before your update must be that your syntax is wrong. Where you say <schema xmlns="urn:oasis:names:tc:dss:1.0:core:schema"> the tool is expecting <schema xmlns="http://www.w3.org/2001/XMLSchema">. To simply import an external XSD file, the above default XML namespace fix it's all you need.

Schema imports/includes can be quite cluttered; for those cases, when one puts them inside of the WSDL, as you have suggested, it is easy to make mistakes, as it is not a simple case of just cut-and-paste. For example, some tools may have issues handling references that originally were based on xsd:include; chameleon includes cannot be reproduced inside a WSDL; and all your xsd:imports MUST NOT use the schemaLocation attribute.

To troubleshoot issues related to broken references, I strongly recommend the use of an HTTP debugger, such as Fiddler. It'll tell you at least what references you forgot to clean, or any HTTP headers that your mock solution does not set properly.

If the above still leaves you with some questions, you will have to post your modified WSDL.

like image 181
Petru Gardea Avatar answered Nov 15 '22 18:11

Petru Gardea