WSDL web reference problem

Discussion in 'ASP .Net Web Services' started by Adrian Parker, Nov 28, 2006.

  1. I have to write a windows service app that consumes a web service provided
    by the UK government. The only info I have is on this page..

    http://www.hmrc.gov.uk/ebu/paye_techpack/dps.htm

    The API specification doesn't give a discovery URL, but there are two WSDL
    zip downloads.. one for a test service and one for a live service.

    In the past, in VS2003, I've added a web reference to a web service where
    you put a URL in and then you have access to the proxy, but I've no idea
    what to do with the two WSDL files.. I've tried referencing them directly
    in add web reference on the local filepath, one loads ok, but the other
    returns a load of
    errors..

    The document at the url file:///C:/dotnet2/egov/testWSDL/dps.wsdl was not
    recognized as a known document type.
    The error message from each known type may help you fix the problem:
    - Report from 'DISCO Document' is 'Unexpected XML declaration. The XML
    declaration must be the first node in the document, and no white space
    characters are allowed to appear before it. Line 2, position 3.'.
    - Report from 'WSDL Document' is 'There is an error in XML document (2,
    3).'.
    - Unexpected XML declaration. The XML declaration must be the first node
    in the document, and no white space characters are allowed to appear before
    it. Line 2, position 3.
    - Report from 'XML Schema' is 'Unexpected XML declaration. The XML
    declaration must be the first node in the document, and no white space
    characters are allowed to appear before it. Line 2, position 3.'.

    Questions..

    1. How should I be referencing these WSDL files
    2. How can I easily switch between then when switching from test to live ?

    --
    Adrian Parker
    Ingenuity At Work Ltd
     
    Adrian Parker, Nov 28, 2006
    #1
    1. Advertising

  2. Hello Adrian,

    Based on your scenario, you're going to consume two webservice from UK
    government and currently what you can get are two wsdl zip packages and you
    met some problems creating client proxy against the wsdl package, correct?

    As for the VS IDE's add webreference Or the .net framework's wsdl.exe tool,
    they can create webservice proxy against both a http based online wsdl
    document or a local WSDL document (on file system). Therefore, for your
    scenario, you can simply add the webreference against the local file system
    path. e.g.

    d:\temp\wsdldoc\dps.wsdl


    for the error you mentioned:

    ==========
    Report from 'DISCO Document' is 'Unexpected XML declaration. The XML
    declaration must be the first node in the document, and no white space
    characters are allowed to appear before it. Line 2, position 3.'.
    ===========

    I've just downloaded the two packages and tried adding webreference on my
    local machine and did get this error when tried adding reference against
    the "dps.wsdl" in the test service(not liveservice). the problem is
    actually caused by the first comment line in the wsdl file as below:

    ====dps.wsdl===
    <!-- v1.0 16/11/2005 -->
    <?xml version="1.0" encoding="utf-8"?>
    <definitions xmlns="http://schemas.xmlsoap.org/wsdl/"
    xmlns:conv="http://www.openuri.org/2002/04/soap/conversation/"
    xmlns:cw="http://www.openuri.org/2002/04/wsdl/conversation/"
    xmlns:http="http://schemas.xmlsoap.org/wsdl/http/"

    ................
    ================


    You can simply remove the "<!-- v1.0 16/11/2005 -->" line, after that the
    proxy can be created correctly.

    Please have a try on it and if there is any other questions, please feel
    free to let me know.

    Sincerely,

    Steven Cheng

    Microsoft MSDN Online Support Lead



    ==================================================

    Get notification to my posts through email? Please refer to
    http://msdn.microsoft.com/subscriptions/managednewsgroups/default.aspx#notif
    ications.



    Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
    where an initial response from the community or a Microsoft Support
    Engineer within 1 business day is acceptable. Please note that each follow
    up response may take approximately 2 business days as the support
    professional working with you may need further investigation to reach the
    most efficient resolution. The offering is not appropriate for situations
    that require urgent, real-time or phone-based interactions or complex
    project analysis and dump analysis issues. Issues of this nature are best
    handled working with a dedicated Microsoft Support Engineer by contacting
    Microsoft Customer Support Services (CSS) at
    http://msdn.microsoft.com/subscriptions/support/default.aspx.

    ==================================================



    This posting is provided "AS IS" with no warranties, and confers no rights.
     
    Steven Cheng[MSFT], Nov 29, 2006
    #2
    1. Advertising

  3. Steven, thanks for the reply..

    Any idea how to switch between the test and the live service.. ? i.e. is
    there a programatic way of doing it or should I create two projects inside
    the same solution which reference the two different sets of files ?



    "Steven Cheng[MSFT]" <> wrote in message
    news:...
    | Hello Adrian,
    |
    | Based on your scenario, you're going to consume two webservice from UK
    | government and currently what you can get are two wsdl zip packages and
    you
    | met some problems creating client proxy against the wsdl package, correct?
    |
    | As for the VS IDE's add webreference Or the .net framework's wsdl.exe
    tool,
    | they can create webservice proxy against both a http based online wsdl
    | document or a local WSDL document (on file system). Therefore, for your
    | scenario, you can simply add the webreference against the local file
    system
    | path. e.g.
    |
    | d:\temp\wsdldoc\dps.wsdl
    |
    |
    | for the error you mentioned:
    |
    | ==========
    | Report from 'DISCO Document' is 'Unexpected XML declaration. The XML
    | declaration must be the first node in the document, and no white space
    | characters are allowed to appear before it. Line 2, position 3.'.
    | ===========
    |
    | I've just downloaded the two packages and tried adding webreference on my
    | local machine and did get this error when tried adding reference against
    | the "dps.wsdl" in the test service(not liveservice). the problem is
    | actually caused by the first comment line in the wsdl file as below:
    |
    | ====dps.wsdl===
    | <!-- v1.0 16/11/2005 -->
    | <?xml version="1.0" encoding="utf-8"?>
    | <definitions xmlns="http://schemas.xmlsoap.org/wsdl/"
    | xmlns:conv="http://www.openuri.org/2002/04/soap/conversation/"
    | xmlns:cw="http://www.openuri.org/2002/04/wsdl/conversation/"
    | xmlns:http="http://schemas.xmlsoap.org/wsdl/http/"
    |
    | ...............
    | ================
    |
    |
    | You can simply remove the "<!-- v1.0 16/11/2005 -->" line, after that the
    | proxy can be created correctly.
    |
    | Please have a try on it and if there is any other questions, please feel
    | free to let me know.
    |
    | Sincerely,
    |
    | Steven Cheng
    |
    | Microsoft MSDN Online Support Lead
    |
    |
    |
    | ==================================================
    |
    | Get notification to my posts through email? Please refer to
    |
    http://msdn.microsoft.com/subscriptions/managednewsgroups/default.aspx#notif
    | ications.
    |
    |
    |
    | Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
    | where an initial response from the community or a Microsoft Support
    | Engineer within 1 business day is acceptable. Please note that each follow
    | up response may take approximately 2 business days as the support
    | professional working with you may need further investigation to reach the
    | most efficient resolution. The offering is not appropriate for situations
    | that require urgent, real-time or phone-based interactions or complex
    | project analysis and dump analysis issues. Issues of this nature are best
    | handled working with a dedicated Microsoft Support Engineer by contacting
    | Microsoft Customer Support Services (CSS) at
    | http://msdn.microsoft.com/subscriptions/support/default.aspx.
    |
    | ==================================================
    |
    |
    |
    | This posting is provided "AS IS" with no warranties, and confers no
    rights.
    |
     
    Adrian Parker, Nov 29, 2006
    #3
  4. It looks like their WSDL files are rubbish anyway.. here's the definition
    for a method called DPSRequestToken..

    <s:element name="DPSrequestToken">
    <s:complexType>
    <s:sequence>
    <s:element name="version" type="s:int"/>
    <s:element name="vendorID" type="s:string" minOccurs="0"/>
    </s:sequence>
    </s:complexType>
    </s:element>
    <s:element name="DPSrequestTokenResponse">
    <s:complexType>
    <s:sequence>
    <s:element name="DPSrequestTokenResult" type="s:string"
    minOccurs="0"/>
    </s:sequence>
    </s:complexType>
    </s:element>

    But the API specification says of DPSRequestToken..

    Method: DPSrequestToken
    Parameters
    Credentials String
    Version Integer
    VendorID String
    Return
    Token String

    Given that the WSDL doesn't even mention the Credentials string, there's no
    way it can be right..

    I love working with government systems.


    "Adrian Parker" <> wrote in message
    news:%...
    | Steven, thanks for the reply..
    |
    | Any idea how to switch between the test and the live service.. ? i.e.
    is
    | there a programatic way of doing it or should I create two projects inside
    | the same solution which reference the two different sets of files ?
    |
    |
    |
    | "Steven Cheng[MSFT]" <> wrote in message
    | news:...
    || Hello Adrian,
    ||
    || Based on your scenario, you're going to consume two webservice from UK
    || government and currently what you can get are two wsdl zip packages and
    | you
    || met some problems creating client proxy against the wsdl package,
    correct?
    ||
    || As for the VS IDE's add webreference Or the .net framework's wsdl.exe
    | tool,
    || they can create webservice proxy against both a http based online wsdl
    || document or a local WSDL document (on file system). Therefore, for your
    || scenario, you can simply add the webreference against the local file
    | system
    || path. e.g.
    ||
    || d:\temp\wsdldoc\dps.wsdl
    ||
    ||
    || for the error you mentioned:
    ||
    || ==========
    || Report from 'DISCO Document' is 'Unexpected XML declaration. The XML
    || declaration must be the first node in the document, and no white space
    || characters are allowed to appear before it. Line 2, position 3.'.
    || ===========
    ||
    || I've just downloaded the two packages and tried adding webreference on my
    || local machine and did get this error when tried adding reference against
    || the "dps.wsdl" in the test service(not liveservice). the problem is
    || actually caused by the first comment line in the wsdl file as below:
    ||
    || ====dps.wsdl===
    || <!-- v1.0 16/11/2005 -->
    || <?xml version="1.0" encoding="utf-8"?>
    || <definitions xmlns="http://schemas.xmlsoap.org/wsdl/"
    || xmlns:conv="http://www.openuri.org/2002/04/soap/conversation/"
    || xmlns:cw="http://www.openuri.org/2002/04/wsdl/conversation/"
    || xmlns:http="http://schemas.xmlsoap.org/wsdl/http/"
    ||
    || ...............
    || ================
    ||
    ||
    || You can simply remove the "<!-- v1.0 16/11/2005 -->" line, after that
    the
    || proxy can be created correctly.
    ||
    || Please have a try on it and if there is any other questions, please feel
    || free to let me know.
    ||
    || Sincerely,
    ||
    || Steven Cheng
    ||
    || Microsoft MSDN Online Support Lead
    ||
    ||
    ||
    || ==================================================
    ||
    || Get notification to my posts through email? Please refer to
    ||
    |
    http://msdn.microsoft.com/subscriptions/managednewsgroups/default.aspx#notif
    || ications.
    ||
    ||
    ||
    || Note: The MSDN Managed Newsgroup support offering is for non-urgent
    issues
    || where an initial response from the community or a Microsoft Support
    || Engineer within 1 business day is acceptable. Please note that each
    follow
    || up response may take approximately 2 business days as the support
    || professional working with you may need further investigation to reach the
    || most efficient resolution. The offering is not appropriate for situations
    || that require urgent, real-time or phone-based interactions or complex
    || project analysis and dump analysis issues. Issues of this nature are best
    || handled working with a dedicated Microsoft Support Engineer by contacting
    || Microsoft Customer Support Services (CSS) at
    || http://msdn.microsoft.com/subscriptions/support/default.aspx.
    ||
    || ==================================================
    ||
    ||
    ||
    || This posting is provided "AS IS" with no warranties, and confers no
    | rights.
    ||
    |
    |
     
    Adrian Parker, Nov 29, 2006
    #4
  5. Hello Adrian,

    As for programmatic way to switch between test and live service, I think
    you can consider the following options:

    1. Since the Test service and Live service are of the same schema and
    structure, you can create the client proxies for them and compare the two
    proxies to see whether they're identical. If identical, you can use share a
    single webservice proxy for the two ones and just change the client proxy's
    "Url" property programmtically at runtime.

    e.g

    ServiceProxy proxy = new ServiceProxy();
    proxy.Url = "xxxx";

    proxy.call ...


    2. If the two service can not use the same client proxy, you can just
    create two service proxies for each of them(in the same project rather than
    involve two projects). Then, you can create either one at runtime according
    to which service you want to access.

    How do you think? Please feel free to let me know if you have any other
    questions or concerns.



    Sincerely,

    Steven Cheng

    Microsoft MSDN Online Support Lead



    This posting is provided "AS IS" with no warranties, and confers no rights.
     
    Steven Cheng[MSFT], Dec 1, 2006
    #5
  6. Hi Steven,

    I think it would have to be the last option as the two wsdl files they
    provided are different.. assuming they'll still be different when they're
    corrected.

    "Steven Cheng[MSFT]" <> wrote in message
    news:...
    | Hello Adrian,
    |
    | As for programmatic way to switch between test and live service, I think
    | you can consider the following options:
    |
    | 1. Since the Test service and Live service are of the same schema and
    | structure, you can create the client proxies for them and compare the two
    | proxies to see whether they're identical. If identical, you can use share
    a
    | single webservice proxy for the two ones and just change the client
    proxy's
    | "Url" property programmtically at runtime.
    |
    | e.g
    |
    | ServiceProxy proxy = new ServiceProxy();
    | proxy.Url = "xxxx";
    |
    | proxy.call ...
    |
    |
    | 2. If the two service can not use the same client proxy, you can just
    | create two service proxies for each of them(in the same project rather
    than
    | involve two projects). Then, you can create either one at runtime
    according
    | to which service you want to access.
    |
    | How do you think? Please feel free to let me know if you have any other
    | questions or concerns.
    |
    |
    |
    | Sincerely,
    |
    | Steven Cheng
    |
    | Microsoft MSDN Online Support Lead
    |
    |
    |
    | This posting is provided "AS IS" with no warranties, and confers no
    rights.
    |
     
    Adrian Parker, Dec 1, 2006
    #6
  7. Finally got to the bottom of the difference, the WSDL is right (apart from
    the comment problem)

    The Credentials are actually a WSE security object that is attached to the
    header of the message and not in the body.

    However, I'm still lost as to how to proceed.

    so far...

    I've attached the wsdl file and created a policy and then tried the
    following code but it doesn't work.. what am I missing ?

    Try
    Dim DPSAuthWse As New TestDPSAuth.dpsauthenticationWse
    DPSAuthWse.SetPolicy("DPSPolicy")
    DPSAuthWse.SetClientCredential(New UsernameToken( _
    "userid","password",PasswordOption.SendPlainText))
    TokenArea.Text = DPSAuthWse.DPSrequestToken(1, "1234")
    Catch ex As Exception
    TokenArea.Text = ex.Message
    End Try

    I get an exception of

    "The underlying connection was closed: An unexpected error occurred on a
    send."



    "Steven Cheng[MSFT]" <> wrote in message
    news:...
    | Hello Adrian,
    |
    | As for programmatic way to switch between test and live service, I think
    | you can consider the following options:
    |
    | 1. Since the Test service and Live service are of the same schema and
    | structure, you can create the client proxies for them and compare the two
    | proxies to see whether they're identical. If identical, you can use share
    a
    | single webservice proxy for the two ones and just change the client
    proxy's
    | "Url" property programmtically at runtime.
    |
    | e.g
    |
    | ServiceProxy proxy = new ServiceProxy();
    | proxy.Url = "xxxx";
    |
    | proxy.call ...
    |
    |
    | 2. If the two service can not use the same client proxy, you can just
    | create two service proxies for each of them(in the same project rather
    than
    | involve two projects). Then, you can create either one at runtime
    according
    | to which service you want to access.
    |
    | How do you think? Please feel free to let me know if you have any other
    | questions or concerns.
    |
    |
    |
    | Sincerely,
    |
    | Steven Cheng
    |
    | Microsoft MSDN Online Support Lead
    |
    |
    |
    | This posting is provided "AS IS" with no warranties, and confers no
    rights.
    |
     
    Adrian Parker, Dec 1, 2006
    #7
  8. Thanks for your followup Adrian,

    I haven't expected that this is a WSE secured webservice, also as for the
    WSE security object(usernametoken...), how did you find the descrption
    about this? You can provide me the reference link so that I can have a look.

    Generally, as for WSE secured ASP.NET webservice, we need to get the server
    service's security policy and then define our client policy
    correspondingly. For example, when using usernameToken, how did you
    configure the message layer security, such as the server certifricate and
    the whether there is any soap header that need encryption.

    In addition, the error message

    "The underlying connection was closed: An unexpected error occurred on a
    send."

    is a very general one and based on my experience, for WSE webservice, it is
    usally occuring when the client-side or server-side's policy/rule
    validation fails......

    Please feel free to let me know if there is any other finding or
    information.



    Sincerely,

    Steven Cheng

    Microsoft MSDN Online Support Lead


    This posting is provided "AS IS" with no warranties, and confers no rights.
     
    Steven Cheng[MSFT], Dec 4, 2006
    #8
  9. Steven,

    The API doc sections 2.1 and 3.1 of this pdf talk about the WS-Security
    token.

    http://www.hmrc.gov.uk/ebu/paye_techpack/dps-api-v1-1.pdf

    Also examples of the xml that is to be sent are given in this file..

    http://www.hmrc.gov.uk/ebu/paye_techpack/dps-sample-data.zip

    -Adrian


    "Steven Cheng[MSFT]" <> wrote in message
    news:...
    |
    | Thanks for your followup Adrian,
    |
    | I haven't expected that this is a WSE secured webservice, also as for the
    | WSE security object(usernametoken...), how did you find the descrption
    | about this? You can provide me the reference link so that I can have a
    look.
    |
    | Generally, as for WSE secured ASP.NET webservice, we need to get the
    server
    | service's security policy and then define our client policy
    | correspondingly. For example, when using usernameToken, how did you
    | configure the message layer security, such as the server certifricate and
    | the whether there is any soap header that need encryption.
    |
    | In addition, the error message
    |
    | "The underlying connection was closed: An unexpected error occurred on a
    | send."
    |
    | is a very general one and based on my experience, for WSE webservice, it
    is
    | usally occuring when the client-side or server-side's policy/rule
    | validation fails......
    |
    | Please feel free to let me know if there is any other finding or
    | information.
    |
    |
    |
    | Sincerely,
    |
    | Steven Cheng
    |
    | Microsoft MSDN Online Support Lead
    |
    |
    | This posting is provided "AS IS" with no warranties, and confers no
    rights.
    |
    |
    |
    |
    |
     
    Adrian Parker, Dec 6, 2006
    #9
  10. Thanks for your reply Adrian,

    I will have a look at it and will update you if I get any further result.

    Sincerely,

    Steven Cheng

    Microsoft MSDN Online Support Lead


    This posting is provided "AS IS" with no warranties, and confers no rights.
     
    Steven Cheng[MSFT], Dec 8, 2006
    #10
  11. Hi Adrian,

    Have you got any progress on this? Based on the document fragment you
    mentioend, the service require the communication under a SSL/HTTPS channel,
    so that means you do not need to care about additional message layer
    security.

    As for the username token, it should be conform to the ws-security
    standard, you can just use its sample message to construct a template of
    the username token related xml fragment. In addition, "DPSrequestToken"
    should be called to get a encoded session token.

    Sincerely,

    Steven Cheng

    Microsoft MSDN Online Support Lead


    This posting is provided "AS IS" with no warranties, and confers no rights.
     
    Steven Cheng[MSFT], Dec 15, 2006
    #11
  12. Hi Steven,

    Ok, still not getting anywhere with this. One thing I've tried however is
    to install WSE2(sp3) and try to run an example from the gov team.
    However, there seems to be something wrong because 1, the WSE 2 security
    plugin i smissing from the project context menu, and 2, the method wse
    extenstion is not recognised in the code. e.g.

    Dim dps_auth as DPSAuthenticationWse isn't recognised

    I installed the wse2sp3 download, was there a different one I should install
    ?

    Thanks



    "Steven Cheng[MSFT]" <> wrote in message
    news:md7RWo$...
    | Hi Adrian,
    |
    | Have you got any progress on this? Based on the document fragment you
    | mentioend, the service require the communication under a SSL/HTTPS
    channel,
    | so that means you do not need to care about additional message layer
    | security.
    |
    | As for the username token, it should be conform to the ws-security
    | standard, you can just use its sample message to construct a template of
    | the username token related xml fragment. In addition, "DPSrequestToken"
    | should be called to get a encoded session token.
    |
    | Sincerely,
    |
    | Steven Cheng
    |
    | Microsoft MSDN Online Support Lead
    |
    |
    | This posting is provided "AS IS" with no warranties, and confers no
    rights.
    |
     
    Adrian Parker, Jan 9, 2007
    #12
  13. Thanks for your followup Adrian,

    As you said "Dim dps_auth as DPSAuthenticationWse isn't recognised", do
    you mean you directly copy the WSE generated code to the new machine or try
    use VS IDE to generate the WSE proxy on that machine?

    Generally, for WSE , there will have two download package. One is for
    redistribute(deployment), it contains runtime only. Another is for
    development and it will contains the runtime together with ADD-IN,
    document, samples.....

    Below should be the complete one for development environment:

    http://www.microsoft.com/downloads/details.aspx?familyid=1ba1f631-c3e7-420a-
    bc1e-ef18bab66122&displaylang=en

    Sincerely,

    Steven Cheng

    Microsoft MSDN Online Support Lead


    This posting is provided "AS IS" with no warranties, and confers no rights.
     
    Steven Cheng[MSFT], Jan 12, 2007
    #13
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Dark
    Replies:
    1
    Views:
    4,650
    milfar
    Nov 14, 2008
  2. Chris Bedford
    Replies:
    0
    Views:
    599
    Chris Bedford
    Aug 21, 2003
  3. Stephen Edgecombe

    WSDL.EXE: WSDL Import Directive

    Stephen Edgecombe, Aug 13, 2003, in forum: ASP .Net Web Services
    Replies:
    0
    Views:
    261
    Stephen Edgecombe
    Aug 13, 2003
  4. RH
    Replies:
    1
    Views:
    274
    Dino Chiesa [Microsoft]
    May 27, 2004
  5. mrnu

    wsdl.exe fails with WebMethods generated wsdl file

    mrnu, Jun 7, 2004, in forum: ASP .Net Web Services
    Replies:
    0
    Views:
    222
Loading...

Share This Page