Integrating PayPal in C#/.NET Solution using WSDL (SOAP)

后端 未结 2 434

Environment : Visual Studio 2010 Professional .NET Framework 4 C#

Added Service Reference using the following WSDL : https://www.paypalobjects.com/wsdl/Pay

2条回答
  •  轻奢々
    轻奢々 (楼主)
    2020-12-31 23:52

    You have a few problems here, but none should be too painful to resolve. First of all, when I add a Service Reference to the WSDL you link at the top of your post I don't have any of the problems with namespaces that you describe. It could be that your own namespaces/references are conflicting somehow with the auto-generated terms, or perhaps that you selected some strange option during the add reference process? A delete-and-re-add might solve the problem, or I guess you can just ignore it since you've already worked around it. (It is kind of a hassle to edit auto-generated code, however, so you should plan on a fix eventually.)

    To resolve the InvalidOperationException, you probably just need to specify one of the endpoints that Visual Studio has automatically added to your app.config file. You should have something like this in your config file:

    
      
        
        
      
    
    

    You can pass the name of the endpoint you want to the constructor of the proxy class. There are other options to solve this problem, but just specifying an endpoint is easy and clean. (Note: if you don't have this section in your config file, then something went wrong during the Add Service Reference phase. Again I would just suggest resetting your project and re-adding the reference.)

    Finally, you don't want to use a using block when you make use of the proxy class in spite of it being IDisposable. Basically, there's a design bug in WCF.

提交回复
热议问题