服务器未能识别http头soapaction的值,求解

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了服务器未能识别http头soapaction的值,求解相关的知识,希望对你有一定的参考价值。

参考技术A #include <stdio.h>
void main()

int table[8]=1,2,3,4,5,i;
printf("输出原数组:\n");
for(i=0;i<8;i++)
printf("%d ",table[i]);
printf("请对数组重新赋值:\n");
for(i=0;i<8;i++)
printf("请输入第%d个元素:\n",i+1);
scanf("%d",&table[i]);

printf("输出重新赋值数组:\n");
for(i=0;i<8;i++)
printf("%d ",table[i]);


楼主你定义本身就是有一点问题,如果是unsigned char table[8]='1','2','3','4','5','6','7','8'
要不就是
char table[8]="1234567";

SOAP1.1 VS SOAP1.2

 SOAP提升:

目前WebService的协议主要有SOAP1.1和1.2。
两者的命名空间不同。

 

见下页对比

 

SOAP1.1版本与SOAP1.2版本在头信息上存在差异。
SOAP1.1存在SOAPAction的请求头。
SOAP1.2没有SOAPAction的请求头。
基于SOAP1.1生成的WSDL和基于SOAP1.2生成的WSDL也不一样。

 

主要看命名空间


在CXF中两种协议请求的方式也不一样。
1.1为content-Type:text/xm;charset=UTF-8
1.2为content-Type:application/soap+xml;charset=UTF-8

命名空间:

Soap1.1的命名空间:

xmlns:soap=“http://schemas.xmlsoap.org/soap/envelope/ “

Soap1.2 命名空间:

xmlns:soap="http://www.w3.org/2003/05/soap-envelope“

SOAP1.1的HTTP请求头:

POST /xe_cxf2.4_soap12_spring_web/ws/helloworldsoap12?wsdl HTTP/1.1
Content-Type: text/xml; charset=UTF-8
Accept: */*
SOAPAction: ""
User-Agent: Apache CXF 2.4.0
Cache-Control: no-cache
Pragma: no-cache
Host: localhost:6767
Connection: keep-alive
Content-Length: 216

 

注意上面包含SOAPAction且请求方式为text/xml。

 

SOAP1.2的请求头:

POST /xe_cxf2.4_soap12_spring_web/ws/helloworldsoap12?wsdl HTTP/1.1
Content-Type: application/soap+xml; charset=UTF-8
Accept: */*
User-Agent: Apache CXF 2.4.0
Cache-Control: no-cache
Pragma: no-cache
Host: localhost:6767
Connection: keep-alive
Content-Length: 214

 

注意上面没有SOAPAction且类型为soap+xml.

SOAP1.1和1.2的WSDL文件的差别:

在定义Service部分差别如下:
Soap1.1是以:soap:address定义。
Soap1.2是以: soap12:address定义。-jdk1.6不支持12形式的访问。

通过BindingType将项目转到1.2:

在类上面添加以下注解可以使用soap1.2的协议:

@BindingType(value=SOAPBinding.SOAP12HTTP_BINDING)
或在applicationContext.xml中使用binding
<jaxws:binding>
<soap:soapBinding version="1.2" />
</jaxws:binding>

SOAP1.2的调用:

当使用了SOAP12以后,wsimport和Eclipse的WSExplorer都不可以正常使用了。
必须,使用cxf提供的wsdl2java工具生成本地代码。
生成本地代码后,通过cxf内置的拦截器,拦截到以下头信息说明是soap12.

技术图片

SOAP11与SOAP12的调用关系:

技术图片

CXF中两种协议请求的方式也不一样 

Soap1.1以普通方式访问:

使用JaxWsProxyFactoryBean

Soap1.2以指定wsdl地址和命名空间的形式访问:

Service service = Service.create(new URL(“wsdlUrl”),
new QName(“namespace”,”ServiceName”));
SomeClass sc = service.getPort(new QName(“namespace”,”PortName”),
SomeClass.class);
sc.someMethod(someParam);

通过Ajax形式访问:

1、指定contentType:’application/soap+xml;charset=“UTF-8”‘
2、组织使用XML数据,使用SOAP12的命名空间.
(由于代码太多,请见下面的备注)

 

以上是关于服务器未能识别http头soapaction的值,求解的主要内容,如果未能解决你的问题,请参考以下文章

System.Web.Services.Protocols.SoapException: 服务器未能识别 HTTP 头 SOAPAction 的值,此问题如何解决

服务器未能识别http头soapaction的值,求解

如何解决错误? “服务器无法识别 HTTP 标头 SOAPAction 的值”

在发送SOAP请求作为HTTP POST时没有获得SOAPAction头错误

Spring-WS为SOAP版本1.2设置SOAPAction头

如何为 WCF 指定自定义 SoapAction