WSDL web reference problem

A

Adrian Parker

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 ?
 
S

Steven Cheng[MSFT]

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.
 
A

Adrian Parker

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 ?



| 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.
|
 
A

Adrian Parker

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.


| 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 ?
|
|
|
| || 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.
||
|
|
 
S

Steven Cheng[MSFT]

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.
 
A

Adrian Parker

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.

| 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.
|
 
A

Adrian Parker

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."



| 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.
|
 
S

Steven Cheng[MSFT]

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.
 
A

Adrian Parker

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


|
| 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.
|
|
|
|
|
 
S

Steven Cheng[MSFT]

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.
 
S

Steven Cheng[MSFT]

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.
 
A

Adrian Parker

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



| 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.
|
 
S

Steven Cheng[MSFT]

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.
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,708
Messages
2,569,348
Members
44,663
Latest member
XiomaraBla

Latest Threads

Top