<?xml version="1.0" encoding="utf-8" ?>
<wsdl:definitions
xmlns:http="http://schemas.xmlsoap.org/wsdl/http/"
xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
xmlns:s="http://www.w3.org/2001/XMLSchema"
xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/"
xmlns:tns="http://tempuri.org/"
xmlns:tm="http://microsoft.com/wsdl/mime/textMatching/"
xmlns:mime="http://schemas.xmlsoap.org/wsdl/mime/"
targetNamespace="http://tempuri.org/"
xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/">
<wsdl:types>
<s:schema elementFormDefault="qualified"
targetNamespace="http://tempuri.org/">
<s:element name="AddTwoIntegers">
<s:complexType>
<s:sequence>
<s:elementminOccurs="1" maxOccurs="1" name="IntegerOne" type="s:int" />
<s:elementminOccurs="1" maxOccurs="1" name="IntegerTwo" type="s:int" />
</s:sequence>
</s:complexType>
</s:element>
<s:element name="AddTwoIntegersResponse">
<s:complexType>
<s:sequence>
<s:elementminOccurs="1" maxOccurs="1" name="AddTwoIntegersResult" type="s:int" />
</s:sequence>
</s:complexType>
</s:element>
</s:schema>
</wsdl:types>
<wsdl:message name="AddTwoIntegersSoapIn">
<wsdl:part name="parameters" element="tns:AddTwoIntegers" />
</wsdl:message>
<wsdl:message name="AddTwoIntegersSoapOut">
<wsdl:part name="parameters" element="tns:AddTwoIntegersResponse" />
</wsdl:message>
<wsdl:portType name="SimpleServiceSoap">
<wsdl:operation name="AddTwoIntegers">
<wsdl:input message="tns:AddTwoIntegersSoapIn" />
<wsdl:output message="tns:AddTwoIntegersSoapOut" />
</wsdl:operation>
</wsdl:portType>
<wsdl:binding name="SimpleServiceSoap" type="tns:SimpleServiceSoap">
<soap:binding transport="http://schemas.xmlsoap.org/soap/http" style="document" />
<wsdl:operation name="AddTwoIntegers">
<soap:operation soapAction="http://tempuri.org/AddTwoIntegers" style="document" />
<wsdl:input>
<soap:body use="literal" />
</wsdl:input>
<wsdl:output>
<soap:body use="literal" />
</wsdl:output>
</wsdl:operation>
</wsdl:binding>
<wsdl:service name="SimpleService">
<documentation xmlns="http://schemas.xmlsoap.org/wsdl/" />
<wsdl:port name="SimpleServiceSoap" binding="tns:SimpleServiceSoap">
<soap:address location="http://localhost/Develop.NET/Home.Develop.WebServices/SimpleService.asmx"/>
</wsdl:port>
</wsdl:service>
</wsdl:definitions>
function fncAddTwoIntegers(a, b)
{
var oXmlHttp = new ActiveXObject("MSXML2.XMLHTTP");
oXmlHttp.open("POST", "http://localhost/Develop.NET/Home.Develop.WebServices/SimpleService.asmx'", false);
oXmlHttp.setRequestHeader("Content-Type", "text/xml");
oXmlHttp.setRequestHeader("SOAPAction", "http://tempuri.org/AddTwoIntegers");
oXmlHttp.send("
<soap:Envelopexmlns:xsi='http://www.w3.org/2001/XMLSchema-instance'
xmlns:xsd='http://www.w3.org/2001/XMLSchema'
xmlns:soap='http://schemas.xmlsoap.org/soap/envelope/'>
<soap:Body>
<AddTwoIntegersxmlns='http://tempuri.org/'>
<IntegerOne>" + a + "</IntegerOne>
<IntegerTwo>" + b + "</IntegerTwo>
</AddTwoIntegers>
</soap:Body>
</soap:Envelope>");
return oXmlHttp.responseXML.selectSingleNode("http://AddTwoIntegersResult").text;
}
<definitions
name="HelloWorld"
targetNamespace="http://xmlns.oracle.com/HelloWorld"
xmlns="http://schemas.xmlsoap.org/wsdl/"
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 attributeFormDefault="qualified" 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>
</types>
<message name="HelloWorldRequestMessage">
<part name="payload" element="client:HelloWorldProcessRequest"/>
</message>
<message name="HelloWorldResponseMessage">
<part name="payload" element="client:HelloWorldProcessResponse"/>
</message>
<portType name="HelloWorld">
<operation name="process">
<input message="client:HelloWorldRequestMessage"/>
<output message="client:HelloWorldResponseMessage"/>
</operation>
</portType>
<binding name="HelloWorldBinding" type="client: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="client:HelloWorldBinding">
<soap:address location="http://robin:9700/orabpel/default/HelloWorld/1.0"/>
</port>
</service>
<plnk:partnerLinkType name="HelloWorld">
<plnk:role name="HelloWorldProvider">
<plnk:portType name="client:HelloWorld"/>
</plnk:role>
</plnk:partnerLinkType>
</definitions>
import java.net.MalformedURLException;
import java.net.URL;
import java.rmi.RemoteException;
import java.util.Vector;
import javax.xml.namespace.QName;
import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.parsers.FactoryConfigurationError;
import javax.xml.parsers.ParserConfigurationException;
import javax.xml.rpc.ServiceException;
import org.apache.axis.client.Call;
import org.apache.axis.constants.Style;
import org.apache.axis.message.SOAPBodyElement;
import org.apache.xml.serialize.DOMSerializerImpl;
import org.apache.xml.serialize.OutputFormat;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
public class BPELServiceTest {
//service鐨勫懡鍚嶇┖闂?
static final String ns = "http://xmlns.oracle.com/HelloWorld";
public static void main(String args[]){
Call call = null;
try {
call = createCall();
Vector rtn = (Vector) call.invoke(createRequest());
parse(rtn);
} catch (MalformedURLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (RemoteException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (ParserConfigurationException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (FactoryConfigurationError e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
/*
* 鍒涘緩Call瀵硅薄錛屽璁劇疆鐩稿叧灞炴э紝娉ㄦ剰錛氬叾涓殑灞炴у簲璇ユ槸閫氳繃鍒嗘瀽WSDL鏂囦歡鐢辯▼搴忓姩鎬佽幏寰楁潵璧嬪鹼紝
* 榪欓噷鍏ㄩ儴綆鍖栦負闈欐佽祴鍊?BR> */
static Call createCall() throws MalformedURLException, ServiceException{
org.apache.axis.client.Service s = new org.apache.axis.client.Service();
Call call = (Call) s.createCall();
call.setTargetEndpointAddress(new URL("http://robin:9700/orabpel/default/HelloWorld/1.0"));
call.setSOAPActionURI("process");
call.setOperationName("process");
call.setProperty(Call.OPERATION_STYLE_PROPERTY, Style.DOCUMENT.getName());
call.setPortName(new QName(ns, "HelloWorldPort"));
call.setPortTypeName(new QName(ns, "HelloWorld"));
return call;
}
/*
*鍒涘緩璇鋒眰鍙傛暟錛屽疄闄呬笂灝辨槸鏋勫緩DOM鐗囨柇錛屾牴鎹甒eb service瀵硅緭鍏ュ弬鏁扮殑瑕佹眰鏉ユ瀯寤猴紝瑕佸澶嶆潅錛岄兘鍙互瀹炵幇錛?BR> *榪欏氨鏄疍ocuemnt鐨勫ソ澶勶紝鐪佸幓浜嗗鏉傚璞$殑搴忓垪鍖栥?BR> */
static Object[] createRequest() throws ParserConfigurationException, FactoryConfigurationError{
DocumentBuilder db = DocumentBuilderFactory.newInstance().newDocumentBuilder();
Document doc = db.newDocument();
Element root = doc.createElementNS(ns, "HelloWorldProcessRequest");
Element input = doc.createElementNS(ns, "input");
input.appendChild(doc.createTextNode("robin"));
root.appendChild(input);
doc.appendChild(root);
return new Object[]{new SOAPBodyElement(root)};
}
// 瀵硅繑鍥炵粨鏋滆繘琛岃В鏋愶紝騫舵墦鍗般?
static void parse(Vector v) throws Exception{
Document doc = ((SOAPBodyElement) v.get(0)).getAsDocument();
Element root = doc.getDocumentElement();
OutputFormat of = new OutputFormat();
of.setIndent(4);
System.out.println(new DOMSerializerImpl().writeToString(root));
}
}
<?xml version="1.0"?>
<HelloWorldProcessResponse xmlns="http://xmlns.oracle.com/HelloWorld">
<result xmlns="http://xmlns.oracle.com/HelloWorld">robin</result>
</HelloWorldProcessResponse>