通常情况下,在JAX-WS2.0中是利用JAXB将传入的SOAP XML消息转换成JAVA的object,然后调用对应porttype的JAVA类的相应的方法,在完成调用后,再通过JAXB将返回参数转成SOAP XML.
JAX-WS还提供了另一种方法,让我们可以直接操作SOAP XML,通过让对应porttype的JAVA类实现 Provider<Source>接口,当服务器端收到SOAP消息后,会调用 Source invoke(Source payload) 方法,如果需要直接对XML进行操作,不想利用JAXB来做对象和XML的转换,可以用这种机制.
例子:(用CXF发布web service)参照http://blog.csdn.net/kkdelta/archive/2009/03/12/3984312.aspx了解CXF发布的步骤.
1,JAVA 类
package com.cxfwsp.test;
import java.io.StringReader;
import javax.xml.transform.Result;
import javax.xml.transform.Source;
import javax.xml.transform.Transformer;
import javax.xml.transform.TransformerFactory;
import javax.xml.transform.stream.StreamResult;
import javax.xml.transform.stream.StreamSource;
import javax.xml.ws.Provider;
import javax.xml.ws.Service;
import javax.xml.ws.ServiceMode;
import javax.xml.ws.WebServiceProvider;
@WebServicePr ......
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.SharePoint;
using Microsoft.SharePoint.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using System.Xml;
using System.IO;
using System.Data;
using System.Data.Linq;
namespace XmlGetUserInfo
{
public class GetUser:WebPart
{
SPWeb sWeb;
SPUser currUser;
private string AddUser()
{
sWeb = SPControl.GetContextWeb(Context);
currUser = sWeb.CurrentUser;
XElement employees = null;
StringBuilder user = new StringBuilder();
//create and writer xml
//string strFilename = Environment.CurrentDirectory + @"\txtuser.xml";//get filename
string strFilename = System.AppDomain.CurrentDomain.BaseDirectory + @"\txtuser.xml";
if(!File.Exists(strFilename))
{
XmlWriterSettings ......
红色字体为主要代码
jsp页面中
<script language="javascript">
function updateDB(operate){
var objDom=new ActiveXObject("msxml.DomDocument");
var objRoot=objDom.createElement("All");
objDom.appendChild(objRoot);
var k=document.getElementsByName("check"); //选择框
for(var i=0;i<k.length;i++){
if(k[i].checked){ //将选择的数据组合成xml格式的数据
var currentRow=k[i].parentNode.parentNode;
var obj=objDom.createElement("Good");
objRoot.appendChild(obj);
var objNode=objDom.createElement("xl_id");
&nb ......
红色字体为主要代码
jsp页面中
<script language="javascript">
function updateDB(operate){
var objDom=new ActiveXObject("msxml.DomDocument");
var objRoot=objDom.createElement("All");
objDom.appendChild(objRoot);
var k=document.getElementsByName("check"); //选择框
for(var i=0;i<k.length;i++){
if(k[i].checked){ //将选择的数据组合成xml格式的数据
var currentRow=k[i].parentNode.parentNode;
var obj=objDom.createElement("Good");
objRoot.appendChild(obj);
var objNode=objDom.createElement("xl_id");
&nb ......
红色字体为主要代码
jsp页面中
<script language="javascript">
function updateDB(operate){
var objDom=new ActiveXObject("msxml.DomDocument");
var objRoot=objDom.createElement("All");
objDom.appendChild(objRoot);
var k=document.getElementsByName("check"); //选择框
for(var i=0;i<k.length;i++){
if(k[i].checked){ //将选择的数据组合成xml格式的数据
var currentRow=k[i].parentNode.parentNode;
var obj=objDom.createElement("Good");
objRoot.appendChild(obj);
var objNode=objDom.createElement("xl_id");
&nb ......
本文总结了在Python中主要的几种处理XML的方法:
Element Tree
SAX
Dom
使用第三方类库如Amara 2.x, libxml2dom 等
Element Tree
Element Tree是Python 2.5引入的使用简单,快捷的处理方法, 也是Python标准类库推荐的处理XML的方法。
它使用树形节点的形式来读写XML。Element Tree是轻量级的DOM, 所以使用方便且耗资源少。
比如有以下XML文件: sample.xml
<?xml version="1.0" encoding="UTF-8"?>
<users>
<user id="001">
<name>John</name>
<age>25</age>
<phone>12345</phone>
</user>
<user id="002">
<name>Bill</name>
<age>30</age>
<phone>54321</phone>
</user>
<user id="003">
<name>Rex</name>
<age>35</age>
<phone>88888</phone>
</user>
</users>
实例代码如下:
# -*- coding: utf-8 -*-
import sys
from xml.etree import Elem ......
本文总结了在Python中主要的几种处理XML的方法:
Element Tree
SAX
Dom
使用第三方类库如Amara 2.x, libxml2dom 等
Element Tree
Element Tree是Python 2.5引入的使用简单,快捷的处理方法, 也是Python标准类库推荐的处理XML的方法。
它使用树形节点的形式来读写XML。Element Tree是轻量级的DOM, 所以使用方便且耗资源少。
比如有以下XML文件: sample.xml
<?xml version="1.0" encoding="UTF-8"?>
<users>
<user id="001">
<name>John</name>
<age>25</age>
<phone>12345</phone>
</user>
<user id="002">
<name>Bill</name>
<age>30</age>
<phone>54321</phone>
</user>
<user id="003">
<name>Rex</name>
<age>35</age>
<phone>88888</phone>
</user>
</users>
实例代码如下:
# -*- coding: utf-8 -*-
import sys
from xml.etree import Elem ......
set ANSI_NULLS ON
set QUOTED_IDENTIFIER ON
go
create procedure [dbo].[MachiningPayedGetListByCondition]
@CustomerName varchar(50),
@CustomerPhone varchar(50),
@PactNumber varchar(50),
@Ispay bit
as
begin
set nocount on;
SELECT
dp.ID as 'MachiningPayed/@ID',
Orders.ID AS 'MachiningPayed/Order/@ID',
-- Task --
Orders.Task AS 'MachiningPayed/Order/Task/@ID',
Tasks.OrderState as 'MachiningPayed/Order/Task/OrderState',
Tasks.UpdateDate as 'MachiningPayed/Order/Task/UpdateDate',
Tasks.CustomerName as 'MachiningPayed/Order/Task/CustomerName',
Tasks.CustomerPhone as 'MachiningPayed/Order/Task/CustomerPhone',
Tasks.CellPhone as 'MachiningPayed/Order/Task/CellPhone',
Tasks.CustomerAddress as 'MachiningPayed/Order/Task/CustomerAddress',
Tasks.ForemanName as 'MachiningPayed/Order/Task/ForemanName',
&nb ......
data.xml
<?xml version="1.0" encoding="UTF-8"?>
<Items>
<Item ASIN="0446355453"
Author="Sidney Sheldon"
Manufacturer="Warner Books"
ProductGroup="Book"
Title="Master of the Game"/>
<Item ASIN="0446613657"
Author="Sidney Sheldon"
Manufacturer="Warner Books"
ProductGroup="Book"
Title="Are You Afraid of the Dark?"/>
<Item ASIN="0446357421"
Author="Sidney Sheldon"
Manufacturer="Warner Books"
ProductGroup="Book"
Title="If Tomorrow Comes"/>
<Item ASIN="0446607207"
Author="Sidney Sheldon"
Manufacturer="Warner Books"
ProductGroup="Book"
Title="Tell Me Your Dreams"/>
<Item ASIN="0446357448"
Author="Sidney Sheldon"
Manufacturer="Warner ......
总记录数:815; 总页数:136; 每页6 条;
首页 上一页 [3] [4] [5] [6] 7
[8] [9] [10] [11] [12] 下一页 尾页