Axis2 Join WCF (more complete version)

Source: Internet
Author: User

Axis2 Join WCF (more complete version)

Divide basichttpbinding and wshttpbinding two kinds of situation:

First, basichttpbinding a little bit simpler, take a look at the HTTP packet it requires:
Post/wcfservice1/service.svc http/1.1
Content-type:application/soap+xml; Charset=utf-8
host:127.0.0.1:3673
content-length:566
Expect:100-continue
Connection:keep-alive

<s:envelope xmlns:s= "Http://www.w3.org/2003/05/soap-envelope" >
<s:Body>
<myoperation2 xmlns= "http://tempuri.org/" >
<myValue1>3</myValue1>
</MyOperation2>
</s:Body></s:Envelope>

After tcpmon-1.0 to see the package AXIS2, there is a chunk in the head and then no content-length, so in the program Axis2 need to turn off the chunk switch:
_messagecontext.setproperty (httpconstants.chunked, "false");

When the chunk is turned off, it will automatically add Content-length. In addition, Expect 100-continue and connection:keep-alive have not yet been generated, but do not affect AXIS2 calling WCF.

Second, wshttpbinding a little bit more complex
Let's take a look at the packages it needs:
Post/wcfservice1/service.svc http/1.1
Content-type:application/soap+xml; Charset=utf-8;
host:127.0.0.1:3673
content-length:642

<?xml version= ' 1.0 ' encoding= ' UTF-8 '?>
<soapenv:envelope xmlns:soapenv= "Http://www.w3.org/2003/05/soap-envelope" >
<soapenv:header xmlns:wsa= "Http://www.w3.org/2005/08/addressing" >
<wsa:To>http://127.0.0.1:3673/WCFService1/Service.svc</wsa:To>
<wsa:ReplyTo>
<wsa:Address>http://www.w3.org/2005/08/addressing/anonymous</wsa:Address>
</wsa:ReplyTo>
<wsa:MessageID>urn:uuid:651A41AA122CE788291212918783422</wsa:MessageID>
<wsa:Action>http://tempuri.org/IMyService/MyOperation2</wsa:Action>
</soapenv:Header>
<soapenv:Body>
<ns1:myoperation2 xmlns:ns1= "http://tempuri.org/" >
<ns1:myValue1>33</ns1:myValue1>
</ns1:MyOperation2>
</soapenv:Body>
</soapenv:Envelope>

What's the difference between it and basichttpbinding? The difference is that the soapenv:header part is more, and the ws-addressing is used. So to make AXIS2 's ws-addressing enable, how to get? On the internet for a long time, said to be a sample of some, go to see Sample:axis2-1.4\samples\userguide\src\userguide\clients\clientsidemoduleengagement.java
The original to read a axis2.xml such a configuration file

I added this sentence to the longest constructor:
Public Wshttpbinding_imyservicestub (
Org.apache.axis2.context.ConfigurationContext Configurationcontext,
Java.lang.String Targetendpoint, Boolean Useseparatelistener)
{
if (Configurationcontext = = null)
{
File repository = new file ("D:\\Program files\\axis2-1.4\\repository");
if (!repository.exists ()) {
try {
throw new FileNotFoundException ("Repository doesnot Exist");
} catch (FileNotFoundException e) {
TODO auto-generated Catch block
E.printstacktrace ();
}
}
Copy the Loggingmodule.mar to "modules" folder.
Then modify the axis2.xml was generating there according to
Phases that being included in the "Module.xml"
Configurationcontext = Configurationcontextfactory.
Createconfigurationcontextfromfilesystem (Repository.getabsolutepath (),
"D:\\Program files\\axis2-1.4\\conf\\axis2.xml");
}
...
}

Generally installed axis2.xml will be added to all the modules, which will include addressing, so it is valid. Can you try it again, Jane?
Then add the following sentence:
_serviceclient.engagemodule (New Javax.xml.namespace.QName (Org.apache.axis2.Constants.MODULE_ADDRESSING));// The compiler says this is out of date, new don't know how to write, do it first

_serviceclient.getoptions (). Setto (New EndpointReference (HTTP://127.0.0.1:3673/WCFSERVICE1/SERVICE.SVC)); Write the address of <wsa:To> in <soapenv:header>

_serviceclient.getoptions (). SetProperty (Addressingconstants.include_optional_headers, boolean.true); The words in <soapenv:header> only <wsa:To> and <wsa:Action> <wsa:messageid> Where MessageID is a unique number that is automatically generated


Third, Mtom
After the torture above, mtom relatively simple, as long as the WCF server-side open Mtom, and then the client in Axis2.xml has a <parameter name= "Enablemtom" >false</parameter It's good to change to true.

Axis2 Join WCF (more complete version)

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.