none
Running svcutil against Java generated WSDL file RRS feed

  • Question

  • Hi!

    I have been supplied a set of  WSDL and xsd files from a Webservice with the purpose of building a .NET 4.0 client to comunicate with the service. I have imported the WSDL into Visual Studio 2010 with success, and I have build the client around the datastructures imported into the project.

    However starting comunication with the service I realised, that the Policy part from the WSDL was skipped during import. I forund these lines in the Reference.cs:   

        // CODEGEN: The optional WSDL extension element 'PolicyReference' from namespace 'http://schemas.xmlsoap.org/ws/2004/09/policy' was not handled.
        // CODEGEN: The optional WSDL extension element 'PolicyReference' from namespace 'http://schemas.xmlsoap.org/ws/2004/09/policy' was not handled.

    I need to implement Signing of MessageBody to comunicate with the service.

    After some investigation I realised, that Policy is not handled by WCF.exe, and you need svcUtil.exe to be able to handle Policy.

    Since then I have spent some time trying to generate the Refence.cs without success. I keep getting the error:

    Error: Cannot import wsdl:port

    followed by some references

    I have queried this error on the various forums, and this seem allmost a generic error message from svcutil if there is any problem with the WSDL.

    I have tried running svcutil in all possible configurations, also with a reference to the 40 .xsd files supplied (a very long command line!)

    I have succeded in generation code despite error messages, and the resulting code was missing the Policy parts needed for signing the Message Body.

    I am supplying a scrambled version of the WSDL file here. Thank you for any input on this :-)

    <?xml version="1.0" encoding="utf-8"?>
    <definitions xmlns:wssutil="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd" xmlns:wsp="http://schemas.xmlsoap.org/ws/2004/09/policy" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:tns="http://www.sup.com/sup/external" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns="http://schemas.xmlsoap.org/wsdl/" targetNamespace="http://www.supl.com/proj/external" name="SalRecNHSWSX">
      <wsp:UsingPolicy wssutil:Required="true" />
      <wsp:Policy wssutil:Id="Wssp1.2-2007-Wss1.1-X509-Basic256-no-header-signing-no-key-ident">
        <ns1:AsymmetricBinding xmlns:ns1="http://docs.oasis-open.org/ws-sx/ws-securitypolicy/200702">
          <wsp:Policy>
            <ns1:InitiatorToken>
              <wsp:Policy>
                <ns1:X509Token ns1:IncludeToken="http://docs.oasis-open.org/ws-sx/ws-securitypolicy/200702/IncludeToken/AlwaysToRecipient">
                  <wsp:Policy>
                    <ns1:WssX509V3Token11 />
                  </wsp:Policy>
                </ns1:X509Token>
              </wsp:Policy>
            </ns1:InitiatorToken>
            <ns1:RecipientToken>
              <wsp:Policy>
                <ns1:X509Token ns1:IncludeToken="http://docs.oasis-open.org/ws-sx/ws-securitypolicy/200702/IncludeToken/AlwaysToInitiator">
                  <wsp:Policy>
                    <ns1:WssX509V3Token11 />
                  </wsp:Policy>
                </ns1:X509Token>
              </wsp:Policy>
            </ns1:RecipientToken>
            <ns1:AlgorithmSuite>
              <wsp:Policy>
                <ns1:Basic256 />
              </wsp:Policy>
            </ns1:AlgorithmSuite>
            <ns1:Layout>
              <wsp:Policy>
                <ns1:Lax />
              </wsp:Policy>
            </ns1:Layout>
            <ns1:OnlySignEntireHeadersAndBody />
          </wsp:Policy>
        </ns1:AsymmetricBinding>
        <ns2:Wss11 xmlns:ns2="http://docs.oasis-open.org/ws-sx/ws-securitypolicy/200702">
          <wsp:Policy>
            <ns2:MustSupportRefKeyIdentifier />
            <ns2:MustSupportRefIssuerSerial />
            <ns2:MustSupportRefThumbprint />
            <ns2:MustSupportRefEncryptedKey />
            <ns2:RequireSignatureConfirmation />
          </wsp:Policy>
        </ns2:Wss11>
      </wsp:Policy>
      <wsp:Policy wssutil:Id="Wssp1.2-2007-SignBody.xml">
        <ns3:SignedParts xmlns:ns3="http://docs.oasis-open.org/ws-sx/ws-securitypolicy/200702">
          <ns3:Body />
        </ns3:SignedParts>
      </wsp:Policy>
      <types>
        <xsd:schema attributeFormDefault="unqualified" elementFormDefault="qualified" xmlns="http://www.sup.com/sup/external" targetNamespace="http://www.sup.com/sup/external">
          <xsd:include schemaLocation="./SUP_SalRecStructure.xsd" />
          <xsd:include schemaLocation="./SUP_SalRecBatchStructure.xsd" />
          <xsd:include schemaLocation="./SUP_SalRecdeleteStructure.xsd" />
          <xsd:include schemaLocation="./SUP_SalRecdeleteBatchStructure.xsd" />
          <xsd:include schemaLocation="./SUP_SalRecStatusQueryStructure.xsd" />
          <xsd:include schemaLocation="./SUP_SalRecResponsStructure.xsd" />
          <xsd:element name="send">
            <xsd:complexType>
              <xsd:sequence>
                <xsd:element name="SUPSalRecStructure" type="tns:SUPSalRecStructureType" minOccurs="0" />
              </xsd:sequence>
            </xsd:complexType>
          </xsd:element>
          <xsd:element name="sendResponse">
            <xsd:complexType>
              <xsd:sequence>
                <xsd:element name="SUPSalRecResponsStructure" type="tns:SUPSalRecResponsStructureType" minOccurs="0" />
              </xsd:sequence>
            </xsd:complexType>
          </xsd:element>
          <xsd:element name="sendBatch">
            <xsd:complexType>
              <xsd:sequence>
                <xsd:element name="SUPSalRecBatchStructure" type="tns:SUPSalRecBatchStructureType" minOccurs="0" />
              </xsd:sequence>
            </xsd:complexType>
          </xsd:element>
          <xsd:element name="sendBatchResponse">
            <xsd:complexType>
              <xsd:sequence>
                <xsd:element name="SUPSalRecResponsStructure" type="tns:SUPSalRecResponsStructureType" minOccurs="0" />
              </xsd:sequence>
            </xsd:complexType>
          </xsd:element>
          <xsd:element name="delete">
            <xsd:complexType>
              <xsd:sequence>
                <xsd:element name="SUPSalRecdeleteStructure" type="tns:SUPSalRecdeleteStructureType" minOccurs="0" />
              </xsd:sequence>
            </xsd:complexType>
          </xsd:element>
          <xsd:element name="deleteResponse">
            <xsd:complexType>
              <xsd:sequence>
                <xsd:element name="SUPSalRecResponsStructure" type="tns:SUPSalRecResponsStructureType" minOccurs="0" />
              </xsd:sequence>
            </xsd:complexType>
          </xsd:element>
          <xsd:element name="deleteBatch">
            <xsd:complexType>
              <xsd:sequence>
                <xsd:element name="SUPSalRecdeleteBatchStructure" type="tns:SUPSalRecdeleteBatchStructureType" minOccurs="0" />
              </xsd:sequence>
            </xsd:complexType>
          </xsd:element>
          <xsd:element name="deleteBatchResponse">
            <xsd:complexType>
              <xsd:sequence>
                <xsd:element name="SUPSalRecResponsStructure" type="tns:SUPSalRecResponsStructureType" minOccurs="0" />
              </xsd:sequence>
            </xsd:complexType>
          </xsd:element>
          <xsd:element name="status">
            <xsd:complexType>
              <xsd:sequence>
                <xsd:element name="SUPSalRecStatusQueryStructure" type="tns:SUPSalRecStatusQueryStructureType" minOccurs="0" />
              </xsd:sequence>
            </xsd:complexType>
          </xsd:element>
          <xsd:element name="statusResponse">
            <xsd:complexType>
              <xsd:sequence>
                <xsd:element name="SUPSalRecResponsStructure" type="tns:SUPSalRecResponsStructureType" minOccurs="0" />
              </xsd:sequence>
            </xsd:complexType>
          </xsd:element>
        </xsd:schema>
      </types>
      <message name="status">
        <part name="parameters" element="tns:status" />
      </message>
      <message name="statusResponse">
        <part name="parameters" element="tns:statusResponse" />
      </message>
      <message name="send">
        <part name="parameters" element="tns:send" />
      </message>
      <message name="sendResponse">
        <part name="parameters" element="tns:sendResponse" />
      </message>
      <message name="delete">
        <part name="parameters" element="tns:delete" />
      </message>
      <message name="deleteResponse">
        <part name="parameters" element="tns:deleteResponse" />
      </message>
      <message name="sendBatch">
        <part name="parameters" element="tns:sendBatch" />
      </message>
      <message name="sendBatchResponse">
        <part name="parameters" element="tns:sendBatchResponse" />
      </message>
      <message name="deleteBatch">
        <part name="parameters" element="tns:deleteBatch" />
      </message>
      <message name="deleteBatchResponse">
        <part name="parameters" element="tns:deleteBatchResponse" />
      </message>
      <portType name="SalRecNHSWSX">
        <operation name="status">
          <input message="tns:status" />
          <output message="tns:statusResponse" />
        </operation>
        <operation name="send">
          <input message="tns:send" />
          <output message="tns:sendResponse" />
        </operation>
        <operation name="delete">
          <input message="tns:delete" />
          <output message="tns:deleteResponse" />
        </operation>
        <operation name="sendBatch">
          <input message="tns:sendBatch" />
          <output message="tns:sendBatchResponse" />
        </operation>
        <operation name="deleteBatch">
          <input message="tns:deleteBatch" />
          <output message="tns:deleteBatchResponse" />
        </operation>
      </portType>
      <binding name="SalRecNHSWSXPortBinding" type="tns:SalRecNHSWSX">
        <wsp:PolicyReference URI="#Wssp1.2-2007-Wss1.1-X509-Basic256-no-header-signing-no-key-ident" />
        <wsp:PolicyReference URI="#Wssp1.2-2007-SignBody.xml" />
        <soap:binding transport="http://schemas.xmlsoap.org/soap/http" style="document" />
        <operation name="status">
          <soap:operation soapAction="" />
          <input>
            <soap:body use="literal" />
          </input>
          <output>
            <soap:body use="literal" />
          </output>
        </operation>
        <operation name="send">
          <soap:operation soapAction="" />
          <input>
            <soap:body use="literal" />
          </input>
          <output>
            <soap:body use="literal" />
          </output>
        </operation>
        <operation name="delete">
          <soap:operation soapAction="" />
          <input>
            <soap:body use="literal" />
          </input>
          <output>
            <soap:body use="literal" />
          </output>
        </operation>
        <operation name="sendBatch">
          <soap:operation soapAction="" />
          <input>
            <soap:body use="literal" />
          </input>
          <output>
            <soap:body use="literal" />
          </output>
        </operation>
        <operation name="deleteBatch">
          <soap:operation soapAction="" />
          <input>
            <soap:body use="literal" />
          </input>
          <output>
            <soap:body use="literal" />
          </output>
        </operation>
      </binding>
      <service name="SalRecNHSWSX">
        <port name="SalRecNHSWSXPort" binding="tns:SalRecNHSWSXPortBinding">
          <soap:address location="https://test.supl.com/service/SalRecNHSWSX" />
        </port>
      </service>
    </definitions>

    Monday, January 14, 2013 1:32 PM

Answers

All replies


  • I am getting persistant errors trying to consume the service in VS:

    Detail: An exception was thrown in a call to a policy import extension.

    Extension: System.ServiceModel.Channels.SecurityBindingElementImporter

    Error: An unsupported security policy assertion was detected during the security policy import:

    <ns1:AsymmetricBinding xmlns:ns1="http://docs.oasis-open.org/ws-sx/ws-securitypolic/200702">
    
          <wsp:Policy xmlns:wsp="http://schemas.xmlsoap.org/ws/2004/09/policy">
    
            <ns1:InitiatorToken>
    
              <wsp:Policy>
    
                <ns1:X509Token ns1:IncludeToken="http://docs.oasis-open.org/ws-sx/ws-securitypolicy/200702/IncludeToken/AlwaysToRecipient">
    
                  <wsp:Policy>
    
                    <ns1:WssX509V3Token11 />
    
                  </wsp:Policy>
    
                </ns1:X509Token>
    
              </wsp:Policy>
    
            </ns1:InitiatorToken>
    
            <ns1:RecipientToken>
    
              <wsp:Policy>
    
                <ns1:X509Token ns1:IncludeToken="http://docs.oasis-open.org/ws-sx/ws-securitypolicy/200702/IncludeToken/AlwaysToInitiator">
    
                  <wsp:Policy>
    
                    <ns1:...




    Saturday, January 12, 2013 8:29 PM
  • Hi,If you want to inject the ws-security into the request of the service, the better way is to configure a binding with security.

    If you select a binding that enables security and you do not set the ProtectionLevel property anywhere on the contract, all application data will be encrypted and signed.

    Wednesday, January 16, 2013 2:51 AM
  • Thank you MiniPeter!

    My problem is, that it it the first time I work with security on a Webservice.

    As mentioned above I can consume the WSDL into my project, but without the Policy part. When I try taht, I am stopped by Exceptions as shown.

    I have not been able to manually merge the imported proxy with security.

    When I look at the transmitted data from my client it looks OK, but the header that should be there for this service is missing.

    The only way I can se is to handle the exception shown above, so the WSDL can be consumed with the Policy part.

    I just cant se my way through that.

    Wednesday, January 16, 2013 8:31 AM
  • Hi,

    Ws-Policy and WSDL are two different formats used to describe services. You can find the difference from below document. WSDL document consists of five sub-elements, Type, Message, PortType, Binding and Service.

    http://msdn.microsoft.com/en-us/library/ms733802.aspx

    Best Regards.


    Haixia
    MSDN Community Support | Feedback to us
    Develop and promote your apps in Windows Store
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    Thursday, January 17, 2013 3:48 AM
    Moderator
  • I have found, that I can build a binding with the security from the WSDL as a System.ServiceModel.Channels.Binding

    But the service is exposed as a System.Web.Services.Protocols.SoapHttpClientProtocol in the reference.cs

    How do I combine the Binding and the SoapHttpClientProtocol?

    Thursday, January 17, 2013 7:16 PM
  • Hi,

    I am cannot clearly understand what you mean, if you want to use a binding with sercurity, there are  a number of system-provided bindings, e.g BasicHttpBinding, WSHttpBinding.

    #Bindings and Security

    http://msdn.microsoft.com/en-us/library/ms731172.aspx

    And you can set the protection level of the service.

    #Understanding Protection Level

    http://msdn.microsoft.com/en-us/library/aa347692.aspx

    Best Regards.


    Haixia
    MSDN Community Support | Feedback to us
    Develop and promote your apps in Windows Store
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    Monday, January 21, 2013 2:05 AM
    Moderator