我正在尝试将数据添加到Soap管理器中以访问我的项目中的Web服务。
PropertyInfo unameProp =new PropertyInfo();
unameProp.name="userid";
unameProp.type=PropertyInfo.STRING_CLASS;
unameProp.setNamespace(NAME_SPACE);
unameProp.setValue(UserId); /*add your value here*/
request.addProperty(unameProp);//Pass properties to the variable, this will set your value in arg0.
PropertyInfo passwordProp =new PropertyInfo();
passwordProp.name="password";
passwordProp.type=PropertyInfo.STRING_CLASS;
passwordProp.setNamespace(NAME_SPACE);
passwordProp.setValue(Password); /*add your value here*/
request.addProperty(passwordProp);
envelope = new SoapSerializationEnvelope(SoapEnvelope.VER11);
envelope.dotNet = true;
envelope.implicitTypes = true;
envelope.setAddAdornments(true);
这是我的WSDL文件格式
<wsdl:types>
<s:schema elementFormDefault="qualified" targetNamespace="http://noobsol.com/tickr">
<s:element name="UserLogin">
<s:complexType>
<s:sequence>
<s:element minOccurs="0" maxOccurs="1" name="UserId" type="s:string"/>
<s:element minOccurs="0" maxOccurs="1" name="Password" type="s:string"/>
</s:sequence>
</s:complexType>
</s:element>
<s:element name="UserLoginResponse">
<s:complexType>
<s:sequence>
<s:element minOccurs="0" maxOccurs="1" name="UserLoginResult">
<s:complexType mixed="true">
<s:sequence>
<s:any/>
</s:sequence>
</s:complexType>
</s:element>
</s:sequence>
</s:complexType>
</s:element>
</s:schema>
</wsdl:types>
访问此代码后,我将此值记入我的日志cat
response anyType{ErrorCode=1; ErrorMessage=Incorrect Username or Password; UserId=anyType{}; Password=anyType{}; }
这是结果,我来自网络服务.User Id&amp;密码字段完全由Web服务返回,仅用于调试。
我在SO上尝试了各种答案,但无济于事。知道我在这里做错了什么吗?