0

i'm using web reference to consume a web service the problem is with a decimal attribute which is optional , its value is not passed the web service. i tried to add default attribute and give it a default value it works fine , but i can not change my wsdl because i have differenet clients working with it (php,java ... clients) The problem is well described here : msdn post stackoverflow post

So i want to find a way to change the code of the proxy class generated after the creation of yhe web reference , because i'm sure it's a bug caused by this class which treats optional decimal attributes wrongly .

2
  • 1
    Would it hurt for you to post the same content here, so people won't have to visit an external site to answer your question? =) Commented Jul 22, 2013 at 13:29
  • 1
    Maybe you didn't know, but "Add Web Reference" is part of the old ASMX technology. ASMX is a legacy technology, and should not be used for new development. WCF should be used for all new development of web service clients and servers. One hint: Microsoft has retired the ASMX Forum on MSDN. Commented Jul 22, 2013 at 23:16

1 Answer 1

1

Solution 1:

  • Go to your project folder -> Web References -> MyService.
  • In there, there should be a file called Reference.cs ... that's the file that is created. It contains proxy classes for the webservice.

Also, if you don't want to mistakenly update the reference and delete your changes to the file, update the reference in the csproj file. On the bottom of the project file, you'll find url's to all services you're using. Point it to the WSDL in the same folder.

Solution 2:

  • Add the service reference to your project
  • Change your project file and update the url of the service, point it to the wsdl in the same folder as in solution 1
  • Make the necessary changes to the wsdl in the same folder
  • Update the reference in VS ... this will create a new Reference.cs ... it will update the proxy classes

NOTE: Depending on the changes made to the WSDL, it might be the web service on the other side might not be able to 'read' your messages. Making a property obligated instead of optional should not break it though.

Sign up to request clarification or add additional context in comments.

2 Comments

many thanks for your explaination , i just want to know if after changing the "local" wsdl :"Change your project file and update the url of the service, point it to the wsdl in the same folder as in solution 1" ,my web service global wsdl will be changed or not,because as i said i have different clients and i dont wanna change the wsdl ? and many thanks again :))
No, it would be a severe security issue if a webservice client would be able to change the WSDL of a service :-) Visual Studio takes a copy of the server's WSDL and puts it in the folder I specified. If you change that WSDL file, nothing bad will happen. The worst thing that could happen, is that you receive an exception because the webservice can't interpret your request. However, when only changing an optional field to obligated, that should not happen. You're welcome.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.