Cross-platform dynamic WebService address reference

Source: Internet
Author: User

When using PDA (wince) to reference WebService, You need to extract the wbservice address and put it into the configuration file. Two problems are involved here. Materials found online

First, how to extract

2. PDA is a cross-platform

How to extract the data first:

First, we reference the server's WebService In the PDA, for example: ws_sellmanage, and then create a proxy class dynwebservicesell In the PDA project.. CS, and inherit the WebService class. Here it is ws_sellmanage.sw_sellmanage

[System. Diagnostics. debuggerstepthrough (),
System. componentmodel. designercategory ("Code "),
System. Web. Services. webservicebinding (name = "", namespace = "")]
Public class dynwebservicesell: ws_sellmanage.sw_sellmanage// Inherit WebService
{
Public dynwebservicesell (string weburl)
: Base ()
{
This. url = weburl;
}
}

Create an app. config to save the WebService address. As follows:

<? XML version = "1.0" encoding = "UTF-8"?>
<Configuration>
<Deleetask>
<Add key = "ws_sellmanagekey" value = "http: // 190.160.10.79: 80111/WebService/sw_sellmanage.asmx"/>
</Appsettings>
</Configuration>

Then we use the proxy class on the constructor of the PDA form.

 

Dynwebservicesell ws_records = NULL;

Public form1 ()

{

Initializecomponent ();

// Load the XML document...

String Path = system. Io. Path. getdirectoryname (system. reflection. Assembly. getexecutingassembly (). getname (). codebase) + "\ app. config ";

System. xml. xmldocument xmldoc = new system. xml. xmldocument ();

Xmldoc. Load (PATH );

System. xml. xmlnode node = xmldoc. selectsinglenode ("// configuration/appsettings/Add [@ key = 'ws _ sellmanagekey']");

If (node! = NULL)

{

Ws_attributes = new dynwebservicesell (node. attributes ["value"]. value );

}

}

Usage:

Object [] login = ws_sell.login (txtusername. Text. Trim (), txtpassword. Text. Trim (); // login is the WebService Method

 

Second question cross-platform

If the preceding method is used, the following error occurs: "webserver reference" indicates that the server fails to identify the value of the HTTP header soapaction ". There are many solutions to this error on the Internet. What I found here is that we need to add

[Soapdocumentservice (routingstyle = soapserviceroutingstyle. requestelement)]

That is:

/// <Summary>

/// Sw_sellmanage region? Abstract A to be ° A to say ¦ ¡â

/// </Summary>

[WebService (namespace = "http://tempuri.org/")]

[Webservicebinding (conformsto = wsiprofiles. basicprofile1_1)]

[System. componentmodel. toolboxitem (false)]

// RuO? ° A allows? ASP. NET Ajax from the foot? Bengà? Dcall ì ¡â use? Ä? Does Web Server fail ?, Why? Please? ? Cancel? Right? Lower? Rows of D? Note á¡ é Shi °. Zookeeper

// [System. Web. Script. Services. scriptservice]

[Soapdocumentservice (routingstyle = soapserviceroutingstyle. requestelement)]

Public class sw_sellmanage: system. Web. Services. WebService

{

/// <Summary>

/// </Summary>

/// <Returns> </returns>

[Webmethod]

Public object [] login (string username, string password)

{}

}

In this way, no problems will occur.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.