我有一个 BPEL 流程。我想在android中调用它。但我无法理解 wsdl url、命名空间和方法名称。因为我知道错误是因为这个。我正在发送 wsdl 文件和 xsd 文件。
我的 BPEL 流程 wsdl 文件是:
<definitions name="HelloWorld" targetNamespace="http://xmlns.oracle.com/HelloWorld" xmlns="http://schemas.xmlsoap.org/wsdl/" xmlns:tns="http://xmlns.oracle.com/HelloWorld" xmlns:plnk="http://schemas.xmlsoap.org/ws/2003/05/partner-link/" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:client="http://xmlns.oracle.com/HelloWorld">
<types>
<schema xmlns="http://www.w3.org/2001/XMLSchema">
<import namespace="http://xmlns.oracle.com/HelloWorld" schemaLocation="HelloWorld.xsd"/>
</schema>
</types>
<message name="HelloWorldRequestMessage">
<part name="payload" element="tns:HelloWorldProcessRequest"/>
</message>
<message name="HelloWorldResponseMessage">
<part name="payload" element="tns:HelloWorldProcessResponse"/>
</message>
<portType name="HelloWorld">
<operation name="process">
<input message="tns:HelloWorldRequestMessage"/>
<output message="tns:HelloWorldResponseMessage"/>
</operation>
</portType>
<binding name="HelloWorldBinding" type="tns:HelloWorld">
<soap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"/>
<operation name="process">
<soap:operation style="document" soapAction="process"/>
<input>
<soap:body use="literal"/>
</input>
<output>
<soap:body use="literal"/>
</output>
</operation>
</binding>
<service name="HelloWorld">
<port name="HelloWorldPort" binding="tns:HelloWorldBinding">
<soap:address location="http://www.sample.com/orabpel/default/HelloWorld/1.0"/>
</port>
</service>
<plnk:partnerLinkType name="HelloWorld">
<plnk:role name="HelloWorldProvider">
<plnk:portType name="tns:HelloWorld"/>
</plnk:role>
</plnk:partnerLinkType>
</definitions>
我的 xsd 文件是:
<schema attributeFormDefault="unqualified" elementFormDefault="qualified" targetNamespace="http://xmlns.oracle.com/HelloWorld" xmlns="http://www.w3.org/2001/XMLSchema">
<element name="HelloWorldProcessRequest">
<complexType>
<sequence>
<element name="input" type="string"/>
</sequence>
</complexType>
</element>
<element name="HelloWorldProcessResponse">
<complexType>
<sequence>
<element name="result" type="string"/>
</sequence>
</complexType>
</element>
</schema>
我的安卓代码是:
import org.ksoap2.SoapEnvelope;
import org.ksoap2.serialization.PropertyInfo;
import org.ksoap2.serialization.SoapObject;
import org.ksoap2.serialization.SoapPrimitive;
import org.ksoap2.serialization.SoapSerializationEnvelope;
import org.ksoap2.transport.HttpTransportSE;
import android.R.string;
import android.app.Activity;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
public class SOAP_WebService extends Activity
{
private final String NAMESPACE = "http://xmlns.oracle.com/HelloWorld";
private final String URL = "http://http://www.sample.com/orabpel/default/HelloWorld/1.0";
private final String SOAP_ACTION = "http://xmlns.oracle.com/HelloWorld/process";
private final String METHOD_NAME = "process";
public void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.soap_webservice);
Button btnClick = (Button) findViewById(R.id.btnClick);
btnClick.setOnClickListener(new OnClickListener()
{
@Override
public void onClick(View v)
{
callWebservice();
}
});
}
public void callWebservice()
{
SoapObject request = new SoapObject(NAMESPACE, METHOD_NAME);
PropertyInfo weightProp =new PropertyInfo();
weightProp.setName("input");
weightProp.setValue("sample");
weightProp.setType(string.class);
request.addProperty(weightProp);
SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SoapEnvelope.VER11);
envelope.dotNet = false;
envelope.bodyOut = request;
envelope.setOutputSoapObject(request);
HttpTransportSE androidHttpTransport = new HttpTransportSE(URL);
try
{
androidHttpTransport.call(SOAP_ACTION, envelope);
SoapPrimitive response = (SoapPrimitive)envelope.getResponse();
SoapObject obj1 = (SoapObject)envelope.bodyIn;
Log.i("myApp", response.toString());
}
catch (Exception e)
{
e.printStackTrace();
Log.d("Exception Generated", ""+e.getMessage());
}
}
}
我收到以下错误:
01-06 00:32:39.572: W/System.err(317): SoapFault - faultcode: 'null:HelloWorld' faultstring: 'Cannot figure out operation name. Bad SOAPAction or wsa:Action.' faultactor: 'http://xmlns.oracle.com/HelloWorld/process' detail: null 01-06
00:32:39.572: W/System.err(317): at org.ksoap2.serialization.SoapSerializationEnvelope.parseBody(SoapSerializationEnvelope.java:141)
01-06 00:32:39.572: W/System.err(317): at org.ksoap2.SoapEnvelope.parse(SoapEnvelope.java:140) 01-06
00:32:39.582: W/System.err(317): at org.ksoap2.transport.Transport.parseResponse(Transport.java:100) 01-06
00:32:39.582: W/System.err(317): at org.ksoap2.transport.HttpTransportSE.call(HttpTransportSE.java:197)
01-06 00:32:39.582: W/System.err(317): at org.ksoap2.transport.HttpTransportSE.call(HttpTransportSE.java:95)
01-06 00:32:39.582: W/System.err(317): at com.mehul.Web_Service.SOAP_WebService.callWebservice(SOAP_WebService.java:69)
01-06 00:32:39.582: W/System.err(317): at com.mehul.Web_Service.SOAP_WebService$1.onClick(SOAP_WebService.java:40)
01-06 00:32:39.582: W/System.err(317): at android.view.View.performClick(View.java:2408) 01-06 00:32:39.582:
W/System.err(317): at android.view.View$PerformClick.run(View.java:8816) 01-06 00:32:39.582:
W/System.err(317): at android.os.Handler.handleCallback(Handler.java:587) 01-06
00:32:39.582: W/System.err(317): at android.os.Handler.dispatchMessage(Handler.java:92) 01-06
00:32:39.592: W/System.err(317): at android.os.Looper.loop(Looper.java:123) 01-06 00:32:39.592:
W/System.err(317): at android.app.ActivityThread.main(ActivityThread.java:4627) 01-06
00:32:39.592: W/System.err(317): at java.lang.reflect.Method.invokeNative(Native Method) 01-06
00:32:39.592: W/System.err(317): at java.lang.reflect.Method.invoke(Method.java:521) 01-06 00:32:39.592:
W/System.err(317): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868)
01-06 00:32:39.592: W/System.err(317): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626) 01-06
00:32:39.592: W/System.err(317): at dalvik.system.NativeStart.main(Native Method) 01-06 00:32:39.592: D/Exception Generated(317): Cannot figure out operation name. Bad
SOAPAction or wsa:Action.