php-Android客户端:Web服务-我应该使用什么正确的SOAP_ACTION,METHOD_NAME,NAMESPACE和URL?

php-Android客户端:Web服务-我应该使用什么正确的SOAP_ACTION,METHOD_NAME,NAMESPACE和URL?,第1张

概述如果我想使用以下Web服务(help.be只是一个例子,假设它确实存在):http://www.help.be/webservice/webservice_help.php(它是用PHP=客户端选择而不是.NET编写的),并带有以下WSDL:<?xmlversion="1.0"encoding="UTF-8"?><definitionsxmlns="http://schemas.xmlsoap.org/wsdl/"

如果我想使用以下Web服务(help.be只是一个例子,假设它确实存在):http://www.help.be/webservice/webservice_help.php(它是用PHP =客户端选择而不是.NET编写的),并带有以下WSDL:

<?xml version="1.0" enCoding="UTF-8"?><deFinitions xmlns="http://schemas.xmlsoap.org/wsdl/" name="webservice_help" targetnamespace="http://www.help.be/webservice/webservice_help.PHP" xmlns:tns="http://www.help.be/webservice/webservice_help.PHP" xmlns:impl="http://www.help.be/webservice/webservice_help.PHP" xmlns:xsd1="http://www.help.be/webservice/webservice_help.PHP" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:soapenc="http://schemas.xmlsoap.org/soap/enCoding/">  <portType name="webservice_helpPortType">    <operation name="webservice_help">        <input message="tns:Webservice_helpRequest"/>    </operation>    <operation name="getLocation" parameterOrder="input">        <input message="tns:GetLocationRequest"/>        <output message="tns:GetLocationResponse"/>    </operation><?xml version="1.0" enCoding="UTF-8"?><deFinitions xmlns="http://schemas.xmlsoap.org/wsdl/" name="webservice_help" targetnamespace="http://www.help.be/webservice/webservice_help.PHP" xmlns:tns="http://www.help.be/webservice/webservice_help.PHP" xmlns:impl="http://www.help.be/webservice/webservice_help.PHP" xmlns:xsd1="http://www.help.be/webservice/webservice_help.PHP" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:soapenc="http://schemas.xmlsoap.org/soap/enCoding/">    <portType name="webservice_helpPortType">        <operation name="webservice_help">            <input message="tns:Webservice_helpRequest"/>        </operation>        <operation name="getLocation" parameterOrder="input">            <input message="tns:GetLocationRequest"/>            <output message="tns:GetLocationResponse"/>        </operation>        <operation name="getStationDetail" parameterOrder="input">            <input message="tns:GetStationDetailRequest"/>            <output message="tns:GetStationDetailResponse"/>        </operation>        <operation name="getStationList" parameterOrder="input">            <input message="tns:GetStationListRequest"/>            <output message="tns:GetStationListResponse"/>        </operation>    </portType>    <binding name="webservice_helpBinding" type="tns:webservice_helpPortType">        <soap:binding  transport="http://schemas.xmlsoap.org/soap/http"/>        <operation name="webservice_help">            <soap:operation soapAction="urn:webservice_help#webservice_helpServer#webservice_help"/>            <input>                <soap:body use="encoded" namespace="http://www.help.be/webservice/webservice_help.PHP" enCodingStyle="http://schemas.xmlsoap.org/soap/enCoding/"/>            </input>        </operation>        <operation name="getLocation">            <soap:operation soapAction="urn:webservice_help#webservice_helpServer#getLocation"/>            <input>                <soap:body parts="input" use="encoded" namespace="http://www.help.be/webservice/webservice_help.PHP" enCodingStyle="http://schemas.xmlsoap.org/soap/enCoding/"/>            </input>            <output>                <soap:body parts="return" use="encoded" namespace="http://www.help.be/webservice/webservice_help.PHP" enCodingStyle="http://schemas.xmlsoap.org/soap/enCoding/"/>            </output>        </operation>        <operation name="getStationDetail">            <soap:operation soapAction="urn:webservice_help#webservice_helpServer#getStationDetail"/>            <input>                <soap:body parts="input" use="encoded" namespace="http://www.help.be/webservice/webservice_help.PHP" enCodingStyle="http://schemas.xmlsoap.org/soap/enCoding/"/>            </input>            <output>                <soap:body parts="return" use="encoded" namespace="http://www.help.be/webservice/webservice_help.PHP" enCodingStyle="http://schemas.xmlsoap.org/soap/enCoding/"/>            </output>        </operation>        <operation name="getStationList">            <soap:operation soapAction="urn:webservice_help#webservice_helpServer#getStationList"/>            <input>                <soap:body parts="input" use="encoded" namespace="http://www.help.be/webservice/webservice_help.PHP" enCodingStyle="http://schemas.xmlsoap.org/soap/enCoding/"/>            </input>            <output>                <soap:body parts="return" use="encoded" namespace="http://www.help.be/webservice/webservice_help.PHP" enCodingStyle="http://schemas.xmlsoap.org/soap/enCoding/"/>            </output>        </operation>    </binding>    <message name="Webservice_helpRequest"/>    <message name="GetLocationRequest">        <part name="input" type="xsd:array"/>    </message>    <message name="GetLocationResponse">        <part name="return" type="xsd:array"/>    </message>    <message name="GetStationDetailRequest">        <part name="input" type="xsd:array"/>    </message>    <message name="GetStationDetailResponse">        <part name="return" type="xsd:string"/>    </message>    <message name="GetStationListRequest">        <part name="input" type="xsd:array"/>    </message>    <message name="GetStationListResponse">        <part name="return" type="xsd:string"/>    </message>    <service name="webservice_helpService">        <port name="webservice_helpPort" binding="tns:webservice_helpBinding">            <soap:address location="http://www.help.be/webservice/webservice_help.PHP"/>        </port>    </service></deFinitions>@H_419_6@

我应该在下面使用什么是正确的SOAP_ACTION,METHOD_name,nameSPACE,URL?

我已经尝试过了

public class Main extends Activity {    /** Called when the activity is first created. */    private static final String SOAP_ACTION_GETLOCATION = "getLocation";    private static final String METHOD_name_GETLOCATION = "getLocation";                private static final String nameSPACE = "http://www.help.be/webservice/";    private static final String URL = "http://www.help.be/webservice/webservice_help.PHP";    TextVIEw tv;    @SuppressWarnings("unchecked")    @OverrIDe    public voID onCreate(Bundle savedInstanceState) {        super.onCreate(savedInstanceState);        setContentVIEw(R.layout.main);        tv = (TextVIEw)findVIEwByID(R.ID.TextVIEw01);        // --------------------------------------------------------------------------------------        SoapObject request_location = new SoapObject(nameSPACE, METHOD_name_GETLOCATION);               request_location.addProperty("login", "login");         // -> string required         request_location.addProperty("password", "password");   // -> string required        request_location.addProperty("serial", "serial");       // -> string required        request_location.addProperty("language", "fr");         // -> string required (available « fr,nl,uk,de »)         request_location.addProperty("keyword", "Braine");      // -> string required        // --------------------------------------------------------------------------------------        SoapSerializationEnvelope soapEnvelope = new SoapSerializationEnvelope(SoapEnvelope.VER11);        //soapEnvelope.dotNet = true;                           // don't forget it for .NET WebServices !        soapEnvelope.setoutputSoapObject(request_location);        AndroIDhttpTransport aht = new AndroIDhttpTransport(URL);        try {             aht.call(SOAP_ACTION_GETLOCATION, soapEnvelope);             // Get the SAOP Envelope back and then extract the body             SoapObject resultsRequestSOAP = (SoapObject) soapEnvelope.bodyIn;             Vector XXXX = (Vector) resultsRequestSOAP.getProperty("GetLocationResponse");             int vector_size = XXXX.size();             Log.i("Hub", "testat="+vector_size);            tv.setText("OK");          } catch(Exception E) {             tv.setText("ERROR:" + E.getClass().getname() + ": " + E.getMessage());            Log.i("Hub", "Exception E");            Log.i("Hub", "E.getClass().getname()="+E.getClass().getname());             Log.i("Hub", "E.getMessage()="+E.getMessage());         }         // --------------------------------------------------------------------------------------    }}@H_419_6@

我不确定必须使用SOAP_ACTION,METHOD_name,nameSPACE和URL吗?因为soapAction指向的是URN而不是传统的URL,它是PHP而不是.NET …

另外,我不确定是否必须使用request_location.addProperty(“ login”,“ login”);
request_location.addAttribute(“ login”,“ login”); ?

=>

<message name="GetLocationRequest"><part name="input" type="xsd:array"/>@H_419_6@

你打算说什么 ?

谢谢您的帮助.

H.

编辑:这是一些在PHP中工作的代码-我只是想拥有相同的代码,但在AndroID / JAVA中:

<?PHP    ini_set("soap.wsdl_cache_enabled", "0"); // disabling WSDL cache     $request['login'] = 'login';    $request['password'] = 'password';    $request['serial'] = 'serial';    $request['language'] = 'fr';      $clIEnt= new SoapClIEnt("http://www.test.be/webservice/webservice_test.wsdl");        print_r( $clIEnt->__getFunctions());    ?><hr><h1>getLocation</h1>    <h2>input:</h2>    <?    $request['keyword'] = 'Bruxelles';    print_r($request);    ?><h2>Result</h2><?     $result = $clIEnt->getLocation($request);     print_r($result);   ?>@H_419_6@

解决方法:

String SOAP_ACTION = "http://tempuri.org/Add";         String METHOD_name = "Add";         String nameSPACE = "http://tempuri.org/";         String URL = "http://www.HTML2xml.nl/Services/Calculator/Version1/Calculator.asmx"; @H_419_6@

以上示例的wsdl可以在以下位置找到:http://www.html2xml.nl/Services/Calculator/Version1/Calculator.asmx?WSDL

就你而言
METHOD_name =“ getStationDetail”或
METHOD_name =“ getStationList”或
METHOD_name =“ getLocation”

总结

以上是内存溢出为你收集整理的php-Android客户端:Web服务-我应该使用什么正确的SOAP_ACTION,METHOD_NAME,NAMESPACE和URL?全部内容,希望文章能够帮你解决php-Android客户端:Web服务-我应该使用什么正确的SOAP_ACTION,METHOD_NAME,NAMESPACE和URL?所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/web/1082191.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-05-27
下一篇 2022-05-27

发表评论

登录后才能评论

评论列表(0条)